TryRebooting
MIS
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
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