#29514 - 2002-09-23 11:19 PM
Copying to remote systems & logging it
|
Anonymous
Anonymous
Unregistered
|
Background: I administer a few dozen win2k pcs that are part of a huge, vast network. I am not a domain admin and I don't have access to a server. All I have is the password for the local admin accounts on all of the win2k boxes.
I wrote a little script to connect to our PCs and copy a file (copying a text file to the desktop is just a test - cause it's easy to check if it worked). Here's the script:
code:
if open (1,"s:\computing\scripts\PCNames.txt") = 0 $pcname = ReadLine(1) WHILE @ERROR = 0 ;? $pcname gosub "map" $pcname = ReadLine(1) LOOP endif goto "end"
:map shell "net use l: \\" + $pcname + "\c$ /user:" + $pcname + "\administrator xxxxxxxxx" copy s:\computing\scripts\pcnames.txt l:\DOCUME~1\ALLUSE~1\Desktop\pcnames.txt ; this IF EXIST is just for me to see on the screen where it works and where it doesn't if exist ("l:\DOCUME~1\ALLUSE~1\Desktop\pcnames.txt") ? $pcname + "File exists..." else ? $pcname + "File didn't exist..." endif ;? $pcname + ".... Copy Error: " + @error shell "net use l: /delete" return
:end close(1)
It's not pretty, but it works. The PC names are stored in the PCNames.txt file
What I can't get to work is this. I'd like a log file to be created that says which PC this worked on and which one it didn't and the date and time I ran the script. The only way I could think of to test if it worked was to test if the file is in the location where it was supposed to be copied to.
When I try to write a log, the first line for the first PC writes, but nothing after. Can someone help me? [BTW, in case it isn't obvious, I took out the failed code for writing the log file from the script above].
And, of course, if there's a better way to do this I sure would appreciate someone telling me how. Many thanks.
|
Top
|
|
|
|
#29518 - 2002-09-24 03:10 PM
Re: Copying to remote systems & logging it
|
Anonymous
Anonymous
Unregistered
|
I took out the code cause it was just plain bad...
Now for the odd part. I ran the script again this morning and it works. I didn't change a thing.
Here it is:
code:
if open (1,"s:\computing\scripts\PCNames.txt") = 0 $pcname = ReadLine(1) WHILE @ERROR = 0 ;? $pcname gosub "map" $pcname = ReadLine(1) LOOP endif goto "end"
:map shell "net use l: \\" + $pcname + "\c$ /user:" + $pcname + "\administrator xxxxxx" copy s:\computing\scripts\pcnames.txt l:\DOCUME~1\ALLUSE~1\Desktop\pcnames.txt if open(2,"S:\computing\scripts\cpstart.log",5) = 0 if exist ("l:\DOCUME~1\ALLUSE~1\Desktop\pcnames.txt") ? $pcname + "File exists..." writeline(2, $pcname + chr(9) + "Yes" + @CRLF) else ? $pcname + "File didn't exist..." writeline(2, $pcname + chr(9) + "No" + @CRLF) endif close(2) endif ;? $pcname + ".... Copy Error: " + @error shell "net use l: /delete" return
:end close(1)
So is there a better way to do all of this? [ 24. September 2002, 15:23: Message edited by: Shane ]
|
Top
|
|
|
|
#29520 - 2002-09-24 03:40 PM
Re: Copying to remote systems & logging it
|
Anonymous
Anonymous
Unregistered
|
Thanks for the suggestions, Jens. Better learn how to work with arrays and ini files...
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 128 anonymous users online.
|
|
|