VBS script that shutdown other pc in network.


  1. Posts : 28
    window 7 ultimate 32 bit
       #1

    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 Computer


  2. Posts : 130
    MSDN Home Premium
       #2

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

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

      My Computer


  3. Posts : 28
    window 7 ultimate 32 bit
    Thread Starter
       #3

    KremmenUK said:
    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


  4. Posts : 28
    window 7 ultimate 32 bit
    Thread Starter
       #4

    timvdhoorn said:
    KremmenUK said:
    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 Computer


  5. Posts : 130
    MSDN Home Premium
       #5

    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


  6. Posts : 28
    window 7 ultimate 32 bit
    Thread Starter
       #6

    KremmenUK said:
    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 Computer


  7. Posts : 28
    window 7 ultimate 32 bit
    Thread Starter
       #7

    Someone Got an sugestion?
      My Computer


  8. Posts : 1
    Windows 7 Ultimate 64-bit
       #8

    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


 

  Related Discussions
Our Sites
Site Links
About 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 07:20.
Find Us