Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MS Print Migrator Script

Status
Not open for further replies.
May 26, 2004
6
US
I put together a script to read a list of computers and run the MS Print Migrator utility to restore a cab file. I need someone to look at the script and provide some feedback. The script works but my scripting skills are limited and I feel it could be better. Thanks in advance for your help.

Dim oFSO, oFile, oErrFile

On Error Resume Next

Const ForReading=1
Const ForWriting=2

If WScript.Arguments.Count=0 Then
strSource=InputBox("Enter the source file containing the computer names")

If strSource="" Then
WScript.Echo "Nothing was entered or you cancelled the script"
WScript.Quit
End If
Else
strSource=WScript.Arguments(0)
End If

Set oFSO=CreateObject("Scripting.FileSystemObject")

If oFSO.FileExists(strSource) Then
Set oFile=oFSO.OpenTextFile(strSource, ForReading)
Else
WScript.Echo "Unable to locate " & strSource
WScript.Quit
End If

Do While oFile.AtEndOfStream<>True
strCmp=UCase(Trim(oFile.ReadLine))
If InStr(" ", strCmp) Then
Else
WScript.Echo "Processing " & strCmp
RunPrintMig strCmp
End If
Loop


Function RunPrintMig(strCmp)

Dim oShell, oENV

strTarget = strCmp
Set oShell = CreateObject("WScript.Shell")
Set oEnv = oShell.Environment("PROCESS")
oENV("SEE_MASK_NOZONECHECKS") = 1
oShell.Run "printmig" & " -r " & "test1.cab" & " \\" & strTarget, 2, True
'printmig -r d:\\print\ps1.cab \\prt-srv1
oENV.Remove("SEE_MASK_NOZONECHECKS")

End Function

 
No problem, I just wanted a more experienced person to look at the script and let me know if it could be better.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top