Re: Sending computer name to txt file if file didnt copy?



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

.



Relevant Pages

  • Re: Finding users in local admin groups
    ... > Here is a vbscript that you can run against a remote computer that moves ... > *local* users except 'Administrator) from the Administrators group to the ... You should also add to the script logging to a file of the ... > you moved on what computers. ...
    (microsoft.public.win2000.security)
  • Re: Change local administrator password ? through GPO or push script ?
    ... I would like to change the local administrator password of every computers member of my AD domain but I am not sure of the best method. ... Create a vbs script that points to the local computer and then deploy this script by GPO. ... This attribute will permit to know wich admin password is configured for this machine. ...
    (microsoft.public.windows.server.active_directory)
  • Re: Not so Newbie
    ... The script is designed for situations like yours. ... wit 35+ computers and to go to each of those computers to individualy ... Prompt for an executable to run on each remote computer in the group. ... so you know where the deployment failed. ...
    (microsoft.public.windows.server.scripting)
  • Re: VBscript that restart the domain comptuer
    ... If you have a shutdown script that cleans up the profiles, ... permissions can restart all computers in a list remotely. ... I have already VB script I ...
    (microsoft.public.windows.server.active_directory)
  • Re: Applying Windows patches via VB
    ... Const OverwriteExisting = True ... ofs.CopyFolder "KB903235",newplace, OverwriteExisting ... strComputer & vbTab) ... >I have been trying to find a suitable script to deploy the Hotfix KB899588 ...
    (microsoft.public.scripting.vbscript)