VBS script that shutdown other pc in network.

timvdhoorn

Banned
Local time
6:13 PM
Messages
28
Hi,

I got an VBS script to shutdown pc in network remote..
PHP:
Option Explicit 
Dim objShell, strComputer, strInput 
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!:cry:
[sorry if its in the wrong section..and sorry for bad english:p]
 

My Computer My Computer

OS
window 7 ultimate 32 bit
Replace the 120 with another variable and ask for this during the InputBox display:

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

 

My Computer My Computer

Computer Manufacturer/Model Number
Novatech (UK) iRush Pro
OS
MSDN Home Premium
CPU
Intel i5
Motherboard
Intel DP55WB
Memory
4Gb
Graphics Card(s)
ATI Radeon HD 5770
Sound Card
On Board
Monitor(s) Displays
Philips 170B
Hard Drives
1 x 1Tb
(7 Partitions)
PSU
750W
Case
Antec 300
Cooling
Tricool Fans
Keyboard
Microsoft 3000 Wireless
Mouse
Microsoft 5000 Wireless BlueTrack
Internet Speed
6.1 Mbps
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 Computer My Computer

OS
window 7 ultimate 32 bit
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 Computer My Computer

Computer Manufacturer/Model Number
Novatech (UK) iRush Pro
OS
MSDN Home Premium
CPU
Intel i5
Motherboard
Intel DP55WB
Memory
4Gb
Graphics Card(s)
ATI Radeon HD 5770
Sound Card
On Board
Monitor(s) Displays
Philips 170B
Hard Drives
1 x 1Tb
(7 Partitions)
PSU
750W
Case
Antec 300
Cooling
Tricool Fans
Keyboard
Microsoft 3000 Wireless
Mouse
Microsoft 5000 Wireless BlueTrack
Internet Speed
6.1 Mbps
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":cry:
thanks anyway
 

My Computer My Computer

OS
window 7 ultimate 32 bit
Someone Got an sugestion?
 

My Computer My Computer

OS
window 7 ultimate 32 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 Computer My Computer

Computer Manufacturer/Model Number
Home built PC
OS
Windows 7 Ultimate 64-bit
CPU
AMD Phenom II X4 985GT
Motherboard
ASUS M4A89GDT Pro USB 3.0
Memory
4 GB RAM
Graphics Card(s)
N/A
Sound Card
Realtek HD Dolby Digital Surround Sound
Monitor(s) Displays
NOC SRS WOW HD
Hard Drives
WD Black 1 TB
PSU
400W Thermaltake
Case
Thermaltake V3
Cooling
Just Fan
Back
Top