Jump to content

Shutdown and restart servers on my network


Chris86
 Share

Recommended Posts

Hi,

I got 3 servers that i have on my network, and i need to restart and shut them down from my computer.

how can i make a script list up all the computers i have on my network(shows the username/computer name)

i need these functions(i can do this myself if someone helps me to list all computers and give me some hints):

"run shutdown -m \\$servername -f -s" to shutdown

"run shutdown -m \\$servername -f -r" to restart

"run shutdown -m \\$servername -f -s -t $time" to shutdown in X seconds

"run shutdown -m \\$servername -f -r -t $time" to restart in X seconds

Link to comment
Share on other sites

;=========================================
; Author : AutoIt Smith
; $Type
;  0 = Logoff
;  1 = Shutdown
;  2 = Reboot
;  4 = Force
;  8 = Power down
;  32= Standby
;  64= Hibernate
;
; $Wait = Time to wait in Seconds.
;=========================================
Func AdvancedShutdown($Type = 0, $Wait = 0)
    Sleep($Wait * 1000)
    Shutdown($Type)
EndFunc

View the Help File next time and Search before posting. There are ways to learning without asking. Use your tools. There are a shitload of resources at your disposal. Hell of a lot more then when I started.

~Smith

Link to comment
Share on other sites

  • Developers

;=========================================
; Author : AutoIt Smith
; $Type
;  0 = Logoff
;  1 = Shutdown
;  2 = Reboot
;  4 = Force
;  8 = Power down
;  32= Standby
;  64= Hibernate
;
; $Wait = Time to wait in Seconds.
;=========================================
Func AdvancedShutdown($Type = 0, $Wait = 0)
    Sleep($Wait * 1000)
    Shutdown($Type)
EndFunc

View the Help File next time and Search before posting. There are ways to learning without asking. Use your tools. There are a shitload of resources at your disposal. Hell of a lot more then when I started.

~Smith

In line with your answer: Maybe read the question first properly before posting a smart-ass reply ..

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.
  :)

Link to comment
Share on other sites

In line with your answer: Maybe read the question first properly before posting a smart-ass reply ..

I gave him a start - now he should listen to the not so smart ass comment and read the help file.

In line with your comment : Maybe read the post unbiased.

Link to comment
Share on other sites

  • Developers

I don't know how to list all my computers on my network.

Does the "Net view" command show what you want ?

:)

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.
  :)

Link to comment
Share on other sites

  • Developers

I gave him a start - now he should listen to the not so smart ass comment and read the help file.

In line with your comment : Maybe read the post unbiased.

mmm .. meaning what ?

I am biased and you where unbiased ...

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.
  :)

Link to comment
Share on other sites

mmm .. meaning what ?

I am biased and you where unbiased ...

Meaning before you immediately think it's a smart ass comment, evaluate the comment from a beginning perspective.

It is true - there are a lot more resources, and it is true you should usually search and look in the help file before posting.

There was not a single smart ass thing in there. It is truth and advice and perhaps will help him in the future when he thinks of scripting.

Link to comment
Share on other sites

  • Developers

Meaning before you immediately think it's a smart ass comment, evaluate the comment from a beginning perspective.

It is true - there are a lot more resources, and it is true you should usually search and look in the help file before posting.

There was not a single smart ass thing in there. It is truth and advice and perhaps will help him in the future when he thinks of scripting.

The OP asked how to list the active computers and said he knew how the reboot remotely using Shutdown.

Your answer was not very helpful and totally missed the asked question.... also telling somebody to: "read the helpfile the next time" is a stupid and smart-ass reply in this case.

- end of hijacking this thread -

Edited by Jos

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.
  :)

Link to comment
Share on other sites

The OP asked how to list the active computers and said he knew how the reboot remotely using Shutdown.

Your answer was not very helpful and totally missed the asked question.... also telling somebody to: "read the helpfile the next time" is a stupid and smart-ass reply in this case.

- end of hijacking this thread -

No it's not. It's advice. That's what I got told when I was starting out - why should it be any different. It is true that searching in the helpfile was all he needed - I choose to give him the shutdown instead of going straight to the question so he can learn to figure it out by himself, and if you think showing someone how to self-teach is stupid, then you are just retarded. 'nuff said.
Link to comment
Share on other sites

  • Developers

But does this work if i dont have any script on the server that retriev these commands?

my idea was to let the command line do the shutdown/restart/hibernate work for me :)

When you need more options than the regular shutdown remotely, you could use a tool like PSShutdown() that has these options. Edited by Jos

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.
  :)

Link to comment
Share on other sites

But does this work if i dont have any script on the server that retriev these commands?

my idea was to let the command line do the shutdown/restart/hibernate work for me :)

Try to learn about TCP. I have a example filled thread in my Signature

Command Line

Command Line Parameters

The special array $CmdLine is initialized with the command line parameters passed in to your AutoIt script. Note the scriptname is not classed as a parameter; get this information with @ScriptName instead. A parameter that contains spaces must be surrounded by "double quotes". Compiled scripts accept command line parameters in the same way.

$CmdLine[0] is number of parameters

$CmdLine[1] is param 1 (after the script name)

$CmdLine[2] is param 2 etc

...

$CmdLine[$CmdLine[0]] is one way to get the last parameter...

So if your script is run like this:

AutoIt3.exe myscript.au3 param1 "this is another param"

$CmdLine[0] equals... 2

$CmdLine[1] equals... param1

$CmdLine[2] equals... this is another param

@ScriptName equals... myscript.au3

In addition to $CmdLine there is a variable called $CmdLineRaw that contains the entire command line unsplit, so for the above example:

$CmdLineRaw equals... myscript.au3 param1 "this is another param"

If the script was compiled it would have been run like this:

myscript.exe param1 "this is another param"

$CmdLineRaw equals... param1 "this is another param"

Note that $CmdLineRaw just return the parameters.

Note : only 63 parameters can be return by $CmdLine[...], but $CmdLineRaw will always returns the entire command line.

Link to comment
Share on other sites

  • Developers

No it's not. It's advice. That's what I got told when I was starting out - why should it be any different. It is true that searching in the helpfile was all he needed - I choose to give him the shutdown instead of going straight to the question so he can learn to figure it out by himself, and if you think showing someone how to self-teach is stupid, then you are just retarded. 'nuff said.

Does Shutdown() work on a remote compute as requested ?

And better watch who you are calling retarded because that person might not like that ...

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.
  :)

Link to comment
Share on other sites

how can i make a script list up all the computers i have on my network(shows the username/computer name)

i need these functions(i can do this myself if someone helps me to list all computers and give me some hints):

Pay attention boys ..... he wants to list the computers .. point him in that direction and drop all the childish banter. Edited by Fossil Rock

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

My-Colors.jpg

cuniform2.gif

Link to comment
Share on other sites

Does Shutdown() work on a remote compute as requested ?

And better watch who you are calling retarded because that person might not like that ...

It's my opinion - if you think self-teaching is wrong. Deal with it and don't go on a power trip over it. And no Shutdown doesn't work remotely - but remember this is SUPPORT not Script Request. Edited by AutoIt Smith
Link to comment
Share on other sites

  • Developers

Pay attention boys ..... he wants to list the servers .. point him in that direction

Think I did that too with the suggestion checking out "net view" ^_^

.... and drop all the childish banter.

Yes sir :)

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.
  :)

Link to comment
Share on other sites

suddenly someone understands :)

I want the script to find all the servers and computers on the network, then i want some functions how it should restart, shutdown and hibernate the server/computer(scroll to the top)

Edit: i forgot to tell you that i want the script to force the server or computer to restart ect.

Edited by Chris86
Link to comment
Share on other sites

  • Developers

And no Shutdown doesn't work remotely - but remember this is SUPPORT not Script Request.

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)

suddenly someone understands ^_^

I want the script to find all the servers and computers on the network, then i want some functions how it should restart, shutdown and hibernate the server/computer(scroll to the top)

Edit: i forgot to tell you that i want the script to force the server or computer to restart ect.

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

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.
  :)

Link to comment
Share on other sites

suddenly someone understands :)

I want the script to find all the servers and computers on the network, then i want some functions how it should restart, shutdown and hibernate(scroll to the top)

Just because you want something doesn't mean we are going to build it. This isn't script request.

Check out TCP. You can use that for communication if it's going to be long distance(IE Not in the same network - or if you need to tell it something more). For network commands look in the AutoIt Help File for NetView and such. You can use Shutdown with any number of parameters - not sure if you can combine types but you can use BitOR for that.

In my Signature - TCP - you should find Remote Server, and it you search the forums there are a number of other Remote Server scripts available to you with Shutdown functions.

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...