script to copy file to multiple computers

W

wuzzle

I can't see what I am doing wrong. I modified this script that I
found on MS web site

Const ForReading = 1
Const OverwriteExisting = TRUE

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\Scripts\Computers.txt")

Do Until objFile.AtEndOfStream
strComputer = objFile.ReadLine
strRemoteFile = "\\" & strComputer & "\C$\windows
\system32\winexit.scr"
objFSO.CopyFile "C:\Program Files\Windows Resource Kits\Tools
\winexit.scr", strRemoteFile, OverwriteExisting
Loop
 
P

Pegasus [MVP]

wuzzle said:
I can't see what I am doing wrong. I modified this script that I
found on MS web site

Const ForReading = 1
Const OverwriteExisting = TRUE

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\Scripts\Computers.txt")

Do Until objFile.AtEndOfStream
strComputer = objFile.ReadLine
strRemoteFile = "\\" & strComputer & "\C$\windows
\system32\winexit.scr"
objFSO.CopyFile "C:\Program Files\Windows Resource Kits\Tools
\winexit.scr", strRemoteFile, OverwriteExisting
Loop

If you're not familiar with VB Scripts, why don't you keep things simple and
use a batch file instead? It would give you much clearer error messages too.
Here is one that would do the trick:

@echo off
set src=C:\Program Files\Windows Resource Kits\Tools
for /F %%a in (c:\Scripts\Computers.txt) do (
copy "%src%\winexit.scr" \\%%a\c$\windows\system32\
)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top