I have taken this script from a website to do a silent install of the
microsoft antispyware software
The only problem is that it cant connect to the IP addresses that I specify
in the txt file - it works fine if I put the IP addres of my own PC in but
not anyone elses on the network??!!
any ideas - script below??
the files are on my PC hard-drive - we are all runnning XP professional SP2
on a windows 2003 server.
Cheers ears
'MSAS Install Script - ryan@overdose.net
admin_user = "someone"
admin_user_password = "something"
'ipFile = path to list of hosts
ipFile = "C:\scripts\installmsas\list.txt"
'execPath = path to executable file
execPath = "C:\scripts\installmsas\msantispy.msi"
'execCommand = command to execute, including path, switches, etc
execCommand = "msiexec.exe /i c:\msantispy.msi /qn INSTALLDIR=c:\MSAS\"
execCommand2 = "C:\msas\gcasDtServ.exe /regserver"
'fileName = filename of executable
fileName = "msantispy.msi"
'pathToLog = path to the logfile
pathToLog = "C:\scripts\installmsas\install_log.txt"
On Error Resume Next
Set oNet = CreateObject("WScript.Network")
Set oFS = CreateObject("Scripting.FileSystemObject")
Set oSvcLocal = GetObject("winmgmts:root\cimv2")
Set oIPFile = oFS.OpenTextFile(ipFile, 1, false)
Set oOutputFile = oFS.CreateTextFile(pathToLog, TRUE)
If (Err.Number <> 0) Then
WScript.Echo "Cannot open " & ipFile
WScript.Quit
End If
While Not oIPFile.atEndOfStream
ip = oipFile.ReadLine()
oOutputFile.WriteLine(vbCrLf & "Connecting to " & ip & "... ")
WScript.Echo vbCrLf & "Connecting to " & ip & "... "
Err.Clear
Set oSvcRemote = GetObject("winmgmts:\\" & ip & "\root\cimv2", _
admin_user, admin_user_password)
If (Err.Number <> 0) Then
oOutputFile.WriteLine("Failed to connect to " & ip & ".")
WScript.Echo "Failed to connect to " & ip & "."
Else
oNet.RemoveNetworkDrive "J:"
oNet.MapNetworkDrive "J:", "\\" & ip & "\C$"
' copy msas file to remote pc
Set oSourceFile = oSvcLocal.Get("cim_datafile=""" & replace(execPath,
"\", "\\") & """")
returnCode = oSourceFile.Copy("J:\\" & fileName)
If (returnCode <> 0 and returnCode <> 10) Then
' Failure detected and failure was not "file already exists."
oOutputFile.WriteLine("Failed copy " & fileName & " to " & ip & " - Error
Code: " & returnCode)
WScript.Echo "Failed copy " & fileName & " to " & ip & " - Error Code: "
& returnCode
oNet.RemoveNetworkDrive "J:"
Else
oOutputFile.WriteLine(fileName & " copied to " & ip)
WScript.Echo fileName & " copied to " & ip
Set oProcess = oSvcRemote.Get("win32_process")
returnCode = oProcess.Create(replace(execCommand, "\",
"\\"))
If (returnCode <> 0) Then
oOutputFile.WriteLine("Failed to start install on "
& ip & " Error Code: " & returnCode)
WScript.Echo "Failed to start install on " & ip & "
Error Code: " & returnCode
oNet.RemoveNetworkDrive "J:"
Else
Set oDestFile = oSvcLocal.Get("cim_datafile=""J:\\"
& fileName & """")
'Wait for the installation to complete.
For waitTime = 0 To 120 ' Lay and wait--up to
two minutes for the installation to complete.
WScript.Sleep 10000 ' Sleep
'Delete temporary file as soon as possible
after it is freed.
If (oDestFile.Delete() = 0) Then
Exit For
End If
Next ' Otherwise, loop again and keep waiting...
oOutputFile.WriteLine("Installation successful on
" & ip & ".")
WScript.Echo "Installation successful on " & ip &
"."
End If 'Create process succeeded.
'now register server
returnCode = oProcess.Create(replace(execCommand2, "\", "\\"))
If (returnCode <> 0) Then
oOutputFile.WriteLine("Failed to register server on
" & ip & " Error Code: " & returnCode)
WScript.Echo "Failed to register server on " & ip &
" Error Code: " & returnCode
Else
oOutputFile.WriteLine("Registration successful on "
& ip & ".")
WScript.Echo "Registration successful on " & ip &
"."
End If
End If
End If
WEnd
oOutputFile.Close