troubleshooting Question

Remote Shutdown by script from text file

Avatar of jhyanagi
jhyanagiFlag for United States of America asked on
VPN
6 Comments1 Solution600 ViewsLast Modified:
I need to run a script to shutdown certain computers on my domain, that I exported in list form from AD.

I have the below script from an earlier and closed post here. It however isn't working. I get the following error.

Script: C:\documents and settings\user\desktop\restarts.vbs
Line:8
Char:1
Error:File not found
Code 800A0035
Source: Microsoft VBScript runtime error

Any assistance would be greatly appreciated.
strInputFile = "C:\PCNames.txt"
 
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set wshShell = WScript.CreateObject ("WScript.shell")
 
Const intForReading = 1
Set objInputFile = objFSO.OpenTextFile(strInputFile, intForReading, False)
While Not objInputFile.AtEndOfStream
      strComputer = objInputFile.ReadLine
      If Ping(strComputer) = True Then
		wshShell.run "shutdown -s -f -t 01 -m \\" & strComputer , 6, True
	  End If
Wend
objInputFile.Close
Set objInputFile = Nothing
 
 
Function Ping(strComputer)
      Dim objShell, boolCode
      Set objShell = CreateObject("WScript.Shell")
      boolCode = objShell.Run("Ping -n 1 -w 300 " & strComputer, 0, True)
      If boolCode = 0 Then
            Ping = True
      Else
            Ping = False
      End If
End Function
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 6 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros