Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: VBS script that shutdown other pc in network.

08 Mar 2011   #1
timvdhoorn

window 7 ultimate 32 bit
 
 
VBS script that shutdown other pc in network.

Hi,

I got an VBS script to shutdown pc in network remote..
Script:
Option Explicit 
Dim objShell
strComputerstrInput 
Dim strShutdown

Do 
strComputer = (InputBox("Computer name""Computer Name")) 
If 
strComputer <> "" Then 
  strInput 
True 
End 
if 
Loop until strInput True

strShutdown 
"shutdown -s -t 120 -f -m \\" strComputer

set objShell 
CreateObject("WScript.Shell")

objShell.run strShutdown

Wscript
.Quit 
And i want that the script asks how long to wait untill the pc shutsdown..(120 in the script)
PLEASE HELP!
[sorry if its in the wrong section..and sorry for bad english]


My System SpecsSystem Spec
.
08 Mar 2011   #2
KremmenUK

MSDN Home Premium
 
 

Replace the 120 with another variable and ask for this during the InputBox display:

strShutdown = "shutdown -s -t" & ShutDownTime & " -f -m \\" & strComputer

My System SpecsSystem Spec
08 Mar 2011   #3
timvdhoorn

window 7 ultimate 32 bit
 
 

Quote   Quote: Originally Posted by KremmenUK View Post
Replace the 120 with another variable and ask for this during the InputBox display:

strShutdown = "shutdown -s -t" & ShutDownTime & " -f -m \\" & strComputer

I get an error
My System SpecsSystem Spec
.

08 Mar 2011   #4
timvdhoorn

window 7 ultimate 32 bit
 
 

Quote   Quote: Originally Posted by timvdhoorn View Post
Quote   Quote: Originally Posted by KremmenUK View Post
Replace the 120 with another variable and ask for this during the InputBox display:

strShutdown = "shutdown -s -t" & ShutDownTime & " -f -m \\" & strComputer

I get an error
O.o The whole script doesn't work........ Pls can you make an other one for me>?
My System SpecsSystem Spec
08 Mar 2011   #5
KremmenUK

MSDN Home Premium
 
 

Option Explicit

Dim objShell, strComputer, strInput
Dim strShutdown
Dim ShutDownTime

strComputer = (InputBox("Computer name", "Computer Name"))
ShutDownTime = (InputBox("ShutDown In... seconds", "Shutdown"))

If trim(strComputer) <> "" and trim(ShutDownTime) <> "" Then

strShutdown = "shutdown -s -t" & ShutDownTime & " -f -m \\" & strComputer

Set objShell = CreateObject("WScript.Shell")

objShell.run strShutdown

Wscript.Quit



I haven't tested it but it should get you closer.............
My System SpecsSystem Spec
08 Mar 2011   #6
timvdhoorn

window 7 ultimate 32 bit
 
 

Quote   Quote: Originally Posted by KremmenUK View Post
Option Explicit

Dim objShell, strComputer, strInput
Dim strShutdown
Dim ShutDownTime

strComputer = (InputBox("Computer name", "Computer Name"))
ShutDownTime = (InputBox("ShutDown In... seconds", "Shutdown"))

If trim(strComputer) <> "" and trim(ShutDownTime) <> "" Then

strShutdown = "shutdown -s -t" & ShutDownTime & " -f -m \\" & strComputer

Set objShell = CreateObject("WScript.Shell")

objShell.run strShutdown

Wscript.Quit



I haven't tested it but it should get you closer.............
Now i get an error Expectect "End"
thanks anyway
My System SpecsSystem Spec
09 Mar 2011   #7
timvdhoorn

window 7 ultimate 32 bit
 
 

Someone Got an sugestion?
My System SpecsSystem Spec
12 Nov 2011   #8
azza1993

Windows 7 Ultimate 64-bit
 
 
Fix

Option Explicit

Dim objShell, strComputer, strInput
Dim strShutdown
Dim ShutDownTime

strComputer = (InputBox("Computer name", "Computer Name"))
ShutDownTime = (InputBox("ShutDown In... seconds", "Shutdown"))

If trim(strComputer) <> "" and trim(ShutDownTime) <> "" Then

strShutdown = "shutdown -s -t " & ShutDownTime & " -f -m \\" & strComputer

Set objShell = CreateObject("WScript.Shell")

objShell.run strShutdown

Wscript.Quit
End If

Notice you didn't finish the If statement. If Then End If is what it should have been.
also there needed to be a space betweem -t and " otherwise it would look like
-t120 instead of -t 120.
Hope this helped
Aaron
My System SpecsSystem Spec
Reply

 VBS script that shutdown other pc in network.




Thread Tools




Similar help and support threads
Thread Forum
Wanting a Script or Program to shutdown PowerDVD13 after ripped movie
Is there anyone that can create some sort of script or small program that could possibly stay alive in the background, watch for when powerdvd13 starts in cinema mode and when the movie stops, have the program shutdown PDVD and bring WMC to the front? - BACKGROUND - -Front End- I am using...
Media Center
Single Monitor shutdown script
Hi I have recently started using multiple monitors but due to my second monitor having a VGA connection it defaults to the primary display when starting up and it shows the bios and windows log on and only once windows has started will it revert back to my DVI primary display. My question is:...
Customization
cannot shutdown after using shutdown script
Hello, I tried adding a shutdown script to my Windows 7 PC. The script is as follows: Set WshShell=WScript.CreateObject("WScript.Shell") On Error Resume Next menuSel=MsgBox("Have you completed your timesheet ?" & vbCrLf & "Have you sent in the Invoice?" & vbCrLf & "Have you forgotten...
General Discussion
Logoff script not running at shutdown
I have a script that launches Ccleaner and needs to run at shutdown. Shutdown scripts do not run within the user space as I understand, so I figured I'd use a logoff script which will run while the user is still logged in. The logoff script works when logging off as expected, but does not run...
General Discussion
Don't want shutdown script to run on restart
Hi, I've got my system configured via gpedit so that it runs a custom batch script when it shuts down. The script can take about a minute to complete because it is telling some external hardware to run through its power down procedure. However when I tell the system to _reboot_ the script...
Software
Is there a way to execute a prgm/script at user logoff/shutdown?
In old WinXP there was a tricky feature in Group Policy editor to execute a script when a User logs off resp. the computer was shutdown. I do not find this feature in Windos 7 (pro). is there another way to execute a *.bat batch script at a) user logoff b) shutdown? Peter
General Discussion


Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 13:12.
Twitter Facebook Google+ Seven Forums iOS App Seven Forums Android App