Here is a .vbs script

function Ping(byval strName)
 dim objFSO, objShell, objTempFile, objTS
 dim sCommand, sReadLine
 dim bReturn

 set objShell = WScript.CreateObject("Wscript.Shell")
 set objFSO = CreateObject("Scripting.FileSystemObject")

 'Set default return value
 bReturn = false

 'Create command line to ping and save results to a temp file
 sCommand = "cmd /c ping.exe -n 3 -w 1000 " & strName & " > temp.txt"

 'Execute the command
 objShell.run sCommand, 0, true

 'Get the temp file
 set objTempFile = objFSO.GetFile("temp.txt")
 set objTS = objTempFile.OpenAsTextStream(1)

 'Loop through the temp file to see if "reply from" is found,
 'if it is then the ping was successful
 do while objTs.AtEndOfStream <> true
  sReadLine = objTs.ReadLine
  if instr(lcase(sReadLine), "reply from") > 0 then
   bReturn = true
   exit do
  end if
 loop

 'Close temp file and release objects
 objTS.close
 objTempFile.delete
 set objTS = nothing
 set objTempFile = nothing
 set objShell = nothing
 set objFSO = nothing

 'Return value
 Ping = bReturn
end function
'/\/\/\/\/\/\/\/\/\/\/\/\/\/\  end function
/\/\/\/\/\/\/\/\/\/\/\/\/\/\
'\/\/\/\/\/\/\/\/\/\/\/\/\/\/\______________/\/\/\/\/\/\/\/\/\/\/\/\/\/\
/



'/\/\/\/\/\/\/\/\/\/\/\ Start Main body of script
/\/\/\/\/\/\/\/\/\/\/\/\
'\/\/\/\/\/\/\/\/\/\/\/\_________________________/\/\/\/\/\/\/\/\/\/\/\/
\/
'Get computer name to operate on
ComputerName=InputBox("Enter the Machine name of the computer" & vbCRLF
_
                    & "you wish to Shutdown / Reboot / Logoff", _
                      "Remote Shutdown / Reboot / Logoff", _
                      "ComputerName")

'if Cancel selected - exit 
If (ComputerName = "") Then Wscript.Quit

'change the name to uppercase
ComputerName=UCase(ComputerName)

'ping the computername to see if it is accessible
bPingtest = ping(Computername)

If bPingtest = FALSE Then
 y = msgbox ("'" & ComputerName & "' is not accessible!" & vbCRLF _
           & "It may be offline or turned off." & vbCRLF _
           & "Check the name for a typo." & vbCRLF, _
              vbCritical, ComputerName & " NOT RESPONDING")
 Wscript.Quit
end IF

'Get the action desired
Action=InputBox( _
    "Select Action to perform on " & ComputerName & vbCRLF & vbCRLF _
  & "  1 - Logoff" & vbCRLF _
  & "  2 - Force Logoff ( NO SAVE )" & vbCRLF _
  & "  3 - Powerdown" & vbCRLF _
  & "  4 - Force Powerdown      ( NO SAVE )" & vbCRLF _
  & "  5 - Reboot" & vbCRLF _
  & "  6 - Force Reboot ( NO SAVE )" & vbCRLF & vbCRLF _
  & "NOTE:" & vbCRLF _
  & "  Using Force will close windows" & vbCRLF _
  & "  without saving changes!", _
    "Select action to perform on " & ComputerName, "")

'if Cancel selected - exit 
If (Action = "") Then Wscript.Quit
 
'error check input
If (INSTR("1234567",Action)=0) OR (Len(Action)>1) then
 y = msgbox("Unacceptable input passed -- '" & Action & "'", _
             vbOKOnly + vbCritical, "That was SOME bad input!")
 Wscript.Quit
end if

' set flag to disallow action unless proper input is achieved, 1 => go 0
=> nogo
flag = 0

'set variables according to computername and action
Select Case Action
  Case 1                                        'Logoff
        x = 0
        strAction = "Logoff sent to " & ComputerName
        flag = 1
  Case 2                                        'Force Logoff   
        x = 4
        strAction = "Force Logoff sent to " & ComputerName
        flag = 1
  Case 3                                        'Powerdown
        x = 8
        strAction = "Powerdown sent to " & ComputerName
        flag = 1
  Case 4                                        'Force Powerdown
        x = 12
        strAction = "Force Powerdown sent to " & ComputerName
        flag = 1
  Case 5                                        'Reboot
        x = 2
        strAction = "Reboot sent to " & ComputerName
        flag = 1
  Case 6                                        'Force Reboot
        x = 6
        strAction = "Force Reboot sent to " & ComputerName
        flag = 1
  Case 7                                        'Test dialog boxes
        y = msgbox("Test complete", vbOKOnly + vbInformation, "Dialog
Box Test Complete")
        flag = 0
  Case Else                                     'Default -- should never
happen
        y = msgbox("Error occurred in passing parameters." _
                  & vbCRLF & "        Passed '" & Action & "'", _
                    vbOKOnly + vbCritical, "PARAMETER ERROR")
        flag = 0
End Select

'check flag
' if equal 1 (TRUE) then perform Win32Shutdown action on remote PC
'   and display a confirmation message
' if not equal 1 (FALSE) then skip the action and script ends
if flag then
 Set OpSysSet=GetObject("winmgmts:{(Debug,RemoteShutdown)}//" _
                   & ComputerName & "/root/cimv2").ExecQuery( _
              "Select * from Win32_OperatingSystem where Primary=true")
 for each OpSys in OpSysSet
  OpSys.Win32Shutdown(x)
  y = msgbox(strAction,vbOKOnly + vbInformation,"Mission Accomplished")
 next
end If

'Release objects
set OpSys = nothing
set OpSysSet = nothing

--------------------------------
Rob Weatherly
Handleman Company
(248) 362-4400 x122
--------------------------------

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] 
Sent: Friday, December 27, 2002 1:24 PM
To: NT 2000 Discussions
Subject: Locked Windows 2000 System

My friend has a locked out Windows 2000 machine. He has admin on the
system,
does anyone know how to do a remote reboot? TIA
Johnny


------
You are subscribed as [EMAIL PROTECTED]
Archives: http://www.swynk.com/sitesearch/search.asp
To unsubscribe send a blank email to %%email.unsub%%

------
You are subscribed as [email protected]
Archives: http://www.swynk.com/sitesearch/search.asp
To unsubscribe send a blank email to [EMAIL PROTECTED]

Reply via email to