Jump to content

Recommended Posts

Posted

Think I did that too with the suggestion checking out "net view" :)

Yes sir ^_^

Yes sir you did and I apologize for over looking that. :)

Agreement is not necessary - thinking for one's self is!

My-Colors.jpg

cuniform2.gif

Posted

C:\>shutdown /?
Usage: shutdown [-i | -l | -s | -r | -a] [-f] [-m \\computername] [-t xx] [-c "c
omment"] [-d up:xx:yy]

        No args              Display this message (same as -?)
        -i                    Display GUI interface, must be the first option
        -l                    Log off (cannot be used with -m option)
        -s                    Shutdown the computer
        -r                    Shutdown and restart the computer
        -a                    Abort a system shutdown
        -m \\computername      Remote computer to shutdown/restart/abort
        -t xx                  Set timeout for shutdown to xx seconds
        -c "comment"            Shutdown comment (maximum of 127 characters)
        -f                    Forces running applications to close without warning
        -d [u][p]:xx:yy      The reason code for the shutdown
                                u is the user code
                                p is a planned shutdown code
                                xx is the major reason code (positive integer less than 256)
                                yy is the minor reason code (positive integer less than 65536)

Did you see the question about "Net view" in this pile of post ? :)

Was talking about AutoIt's Shutdown function..........
Posted

C:\>shutdown /?
Usage: shutdown [-i | -l | -s | -r | -a] [-f] [-m \\computername] [-t xx] [-c "c
omment"] [-d up:xx:yy]

        No args              Display this message (same as -?)
        -i                    Display GUI interface, must be the first option
        -l                    Log off (cannot be used with -m option)
        -s                    Shutdown the computer
        -r                    Shutdown and restart the computer
        -a                    Abort a system shutdown
        -m \\computername      Remote computer to shutdown/restart/abort
        -t xx                  Set timeout for shutdown to xx seconds
        -c "comment"            Shutdown comment (maximum of 127 characters)
        -f                    Forces running applications to close without warning
        -d [u][p]:xx:yy      The reason code for the shutdown
                                u is the user code
                                p is a planned shutdown code
                                xx is the major reason code (positive integer less than 256)
                                yy is the minor reason code (positive integer less than 65536)

Did you see the question about "Net view" in this pile of post ? :)

I have a friend that told me how to shutdown computers with commandline, and then i got an idea how to control my servers.
  • Developers
Posted

I have a friend that told me how to shutdown computers with commandline, and then i got an idea how to control my servers.

I have build several script that ran software upgrades remotely using PSEXEC and PSSHUTDOWN commands supplied by Sysinternals (Microsoft owned these days).

Its a real nice way to do a mass upgrade to remote servers.

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted

@all

This should get you all going (no external tools needed).

#Include <Constants.au3>

$s_Machine = InputBox("Input", "Please enter the name of the computer you want to reboot")
$s_Command = InputBox("Input", "0=Log Off|0+4=Forced Log Off|1=Shutdown|1+4=Forced Shutdown|2=Reboot|2+4=Forced Reboot " & _
                    "|8=Power Off|8+4=Forced Power Off")

_RemoteShutdown($s_Machine, $s_Command)

Func _RemoteShutdown(ByRef $s_Machine, ByRef $s_Command)
    Local $wbemFlagReturnImmediately, $wbemFlagForwardOnly, $objWMIService, $colItems, $objItem
    
    $wbemFlagReturnImmediately = 0x10
    $wbemFlagForwardOnly = 0x20
    $colItems = ""
    $objWMIService = ObjGet("winmgmts:\\" & $s_Machine & "\root\CIMV2")
    $colItems = $objWMIService.ExecQuery("SELECT Name From Win32_OperatingSystem", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
    ; 0=Log Off|0+4=Forced Log Off|1=Shutdown|1+4=Forced Shutdown|2=Reboot|2+4=Forced Reboot|8=Power Off|8+4=Forced Power Off
    For $objItem in $colItems
        $objItem.Win32ShutDown($s_Command)
    Next
EndFunc; ==> _RemoteShutdown

Please keep on smiling :)

regards

ptrex

Posted

@all

This should get you all going (no external tools needed).

#Include <Constants.au3>

$s_Machine = InputBox("Input", "Please enter the name of the computer you want to reboot")
$s_Command = InputBox("Input", "0=Log Off|0+4=Forced Log Off|1=Shutdown|1+4=Forced Shutdown|2=Reboot|2+4=Forced Reboot " & _
                    "|8=Power Off|8+4=Forced Power Off")

_RemoteShutdown($s_Machine, $s_Command)

Func _RemoteShutdown(ByRef $s_Machine, ByRef $s_Command)
    Local $wbemFlagReturnImmediately, $wbemFlagForwardOnly, $objWMIService, $colItems, $objItem
    
    $wbemFlagReturnImmediately = 0x10
    $wbemFlagForwardOnly = 0x20
    $colItems = ""
    $objWMIService = ObjGet("winmgmts:\\" & $s_Machine & "\root\CIMV2")
    $colItems = $objWMIService.ExecQuery("SELECT Name From Win32_OperatingSystem", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
    ; 0=Log Off|0+4=Forced Log Off|1=Shutdown|1+4=Forced Shutdown|2=Reboot|2+4=Forced Reboot|8=Power Off|8+4=Forced Power Off
    For $objItem in $colItems
        $objItem.Win32ShutDown($s_Command)
    Next
EndFunc; ==> _RemoteShutdown

Please keep on smiling :)

regards

ptrex

Very nice code. I could have never thought of that.
Posted

@all

This should get you all going (no external tools needed).

#Include <Constants.au3>

$s_Machine = InputBox("Input", "Please enter the name of the computer you want to reboot")
$s_Command = InputBox("Input", "0=Log Off|0+4=Forced Log Off|1=Shutdown|1+4=Forced Shutdown|2=Reboot|2+4=Forced Reboot " & _
                    "|8=Power Off|8+4=Forced Power Off")

_RemoteShutdown($s_Machine, $s_Command)

Func _RemoteShutdown(ByRef $s_Machine, ByRef $s_Command)
    Local $wbemFlagReturnImmediately, $wbemFlagForwardOnly, $objWMIService, $colItems, $objItem
    
    $wbemFlagReturnImmediately = 0x10
    $wbemFlagForwardOnly = 0x20
    $colItems = ""
    $objWMIService = ObjGet("winmgmts:\\" & $s_Machine & "\root\CIMV2")
    $colItems = $objWMIService.ExecQuery("SELECT Name From Win32_OperatingSystem", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
    ; 0=Log Off|0+4=Forced Log Off|1=Shutdown|1+4=Forced Shutdown|2=Reboot|2+4=Forced Reboot|8=Power Off|8+4=Forced Power Off
    For $objItem in $colItems
        $objItem.Win32ShutDown($s_Command)
    Next
EndFunc; ==> _RemoteShutdown

Please keep on smiling :)

regards

ptrex

got any codes that list all the computers on the network?
Posted

got any codes that list all the computers on the network?

Jos has already provided an authentic answer to this question. Please read through the thread and view where he talks about Net View.
Posted

I think that net view only shows computers in your own workgroup or domain, if you are looking for computers outside of your workgroup (if using workgroups) then your going to need a different method. unfortunately I don't have the answer but I thought I should make you aware :)

Posted

I think that net view only shows computers in your own workgroup or domain, if you are looking for computers outside of your workgroup (if using workgroups) then your going to need a different method. unfortunately I don't have the answer but I thought I should make you aware :)

All my servers are in the same workgroup on my network
  • 2 weeks later...
Posted

While you are using WMI to send the remote shutdown commands, could it also be used to ascertain which ones are visible across the network?

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...