Re: Sending computer name to txt file if file didnt copy?
- From: Carito <Carito@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 27 Aug 2008 06:24:01 -0700
Thanks for the help guys. I'll give it a try. Pretty new to this. I'll also
look intot he MSI etc suggestion. Never had to push out something to close to
150 computers and dont have access to AD to do it that way.
"Owen Gilmore" wrote:
On Aug 26, 2:55 pm, "Pegasus \(MVP\)" <I....@xxxxxxxxxx> wrote:.
"Carito" <Car...@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:71D6D242-CD00-4214-9467-98EB49D82848@xxxxxxxxxxxxxxxx
Not sure if that is confusing. I got some vb code from another post here
but
want to make it dom some extra stuff that I dont know how to handle.
Basically it reads a list of computer names from a text file then copies a
file (ie shortcut in this case) to each of those remote computer's
desktops.
Problem I have is if the computer is turned off or inaccessible for
whatever
reason, I dont have any way of knowing it since the vb error that might
pop
up doesnt reference the computer name and there is no log file created.
So basically I just want to have it create a log file and enter in the
names
of the computers based on what it pulled from the text file and indicate
whether it was successful or not. Not sure how easy that is. Can someone
help?
Here is the code so far that works.
'On Error Resume Next
Const ForReading = 1
Const OverwriteExisting = True
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Read from file list name and location
Set objFile = objFSO.OpenTextFile("C:\mob.txt")
Do Until objFile.AtEndOfStream
strComputer = objFile.ReadLine
'Amend text name and set path to remote location
strRemoteFile = "\\" & strComputer & "\C$\Documents and Settings\All
Users\Desktop\New Icon.url"
'File to Copy
objFSO.CopyFile "C:\3M MNO.url", strRemoteFile, OverwriteExisting
Loop
You need to make your scripts a little more robust. Instead of assuming that
all will go well, assume that it won't and deal with these cases
accordingly. This modified version of your script will inform you if there
is a problem with your CopyFile method (ANY problem, not just a target PC
that cannot be reached!).
You should also close your files when you're finished with them.
Const ForReading = 1
Const OverwriteExisting = True
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Read from file list name and location
Set objFile = objFSO.OpenTextFile("C:\mob.txt")
Do Until objFile.AtEndOfStream
strComputer = objFile.ReadLine
'Append text name and set path to remote location
strRemoteFile = "\\" & strComputer & "\C$\Documents and Settings\All
Users\Desktop\New Icon.url"
'File to Copy
On Error Resume Next
objFSO.CopyFile "C:\3M MNO.url", strRemoteFile, OverwriteExisting
If Err.number > 0 then WScript.Echo "Problem with COPY command on """ &
strComputer & """."
On Error Goto 0
Loop
objFile.Close- Hide quoted text -
- Show quoted text -
I also suspect that hard coding in a c$ share, and a "documents and
settings\all users" path is probably not the best way to go about it.
There must be some way to resolve and localize the %ALLUSERSPROFILE%
environment variable and key off of that.
If all you're trying to do is copy a shortcut I'd be tempted to create
a wise script or an MSI to do it. Lots easier than wrestling with VB
Script.
-OG
- Follow-Ups:
- Re: Sending computer name to txt file if file didnt copy?
- From: Owen Gilmore
- Re: Sending computer name to txt file if file didnt copy?
- References:
- Sending computer name to txt file if file didnt copy?
- From: Carito
- Re: Sending computer name to txt file if file didnt copy?
- From: Pegasus \(MVP\)
- Sending computer name to txt file if file didnt copy?
- Prev by Date: problem with forms
- Next by Date: Re: problem with forms
- Previous by thread: Re: Sending computer name to txt file if file didnt copy?
- Next by thread: Re: Sending computer name to txt file if file didnt copy?
- Index(es):
Relevant Pages
|