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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Shutdown vbs

Status
Not open for further replies.

RNF0528

MIS
Apr 4, 2006
115
US
I am attempting to run a script that will use the shutdown command to reboot my system once a week. I am getting an expected end of statement error...

here is the line with the error

strShutdown = "shutdown /l /r /y /t:14400 /c" "This is a test of the Shutdown system."

The test in the statement must be in qoutes and i think thats were my problem is but i cant figure out the syntax.
 
strShutdown = "shutdown /l /r /y /t:14400 /c ""This is a test of the Shutdown system."""

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
This will work as well:

onst ForReading = 1
Set WshShell = CreateObject("Wscript.shell")
Set objDictionary = CreateObject("Scripting.Dictionary")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile ("c:\PCs.txt", ForReading)
i = 0
Do Until objTextFile.AtEndOfStream
strNextLine = objTextFile.Readline
objDictionary.Add i, strNextLine
i = i + 1
Loop
For Each objItem in objDictionary
strComputer = objDictionary.Item(objItem)
Set OpSysSet = GetObject("winmgmts:{impersonationLevel=impersonate,(RemoteShutdown)}//" & strComputer).ExecQuery("select * from Win32_OperatingSystem where Primary=true")
for each OpSys in OpSysSet
OpSys.Reboot()
next
Next
 
Correction to the above code:
onst ForReading = 1

Should be
[red]C[/red]onst ForReading = 1


I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top