VBS Script Which calls psexec (Full Version)

All Forums >> [Scripting Technologies] >> VB Script



Message


jbolton_99 -> VBS Script Which calls psexec (5/6/2008 9:42:11 AM)

I have a script I found which will call the psexec program on a specified computer then uninstall and reinstall the SMS Client. I was hoping it could be modified too call from a list of computers from a txt file then export the results to another text file.

Right now it will work with the computers that I list in arrComputers =, but if its possible to grab the computer list from a txt file that would help me automate this process. In addition if I could look over the result file I could remove the systems from the list which successfully completed the process.

arrComputers = Array("Computer_Name")
Set objShell = CreateObject("WScript.Shell")
For Each strComputer In arrComputers
     objShell.Run "psexec \\" & strComputer & " -c ccmclean.exe /q", 1, True
     objShell.Run "psexec \\" & strComputer & " regedit.exe /s removeSMSkeys.reg"
     objShell.Run "psexec \\" & strComputer & " -c ccmsetup.exe SMSSITECODE=HQ1 SMSCACHESIZE=300 /q"
Next

Any help or suggestions would be appreciated. Thanks in advance!




vrodrigues -> RE: VBS Script Which calls psexec (5/6/2008 10:50:15 AM)

This should do the trick for inputing a machine list.


Option Explicit

Dim fso
Dim objShell
Dim strComputer
Dim inputFile

Set fso = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("WScript.Shell")
Set inputFile = fso.OpenTextFile("Machine.Txt")

Do While Not (inputFile.atEndOfStream)
     strComputer = inputFile.ReadLine
     objShell.Run "psexec \\" & strComputer & " -c ccmclean.exe /q", 1, True
     objShell.Run "psexec \\" & strComputer & " regedit.exe /s removeSMSkeys.reg"
     objShell.Run "psexec \\" & strComputer & " -c ccmsetup.exe SMSSITECODE=HQ1 SMSCACHESIZE=300 /q"
Loop
inputFile.Close




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.4370117