Jump to content

NET USE and SHUTDOWN in bat-file


pthomass
 Share

Recommended Posts

Hi,

I'm trying to do a shutdown over my network. I can logon to the device(s) with

NET USE \\computername /user:administrator password

and I can shut them down with

SHUTDOWN -s -m \\computername -t 60 -c "Your computer will shutdown in:"

But now I want to put them in a bat file. But I cannot seem to get that to work. The NET USE thingy works. But for the shutdown it gets stuck into a loop of some sort.

Anyone an idea?

Link to comment
Share on other sites

What's happening is the "shutdown" program is never exiting and is thus halting all other execution until it's finished (the nature of a single-tasking OS). You might try invoking a secondary Batch file with the shutdown command in it after the net use command. I'm trying to find how to background a process in batch (similar to the & in *NIX scripts) but my searches are not too promising...

Link to comment
Share on other sites

But why is it then,when I open the DOS window and type

shutdown -s -m \\computername -t 60 -c "Computer will shutdown"

it will excecute only once? I can see on the computer that I want to shutdown that there comes a window that sais that the system will shutdown and that you need to save your work. And you see a timer running.

But, when I put the same line in a bat file and run the bat file, the other computer doesn't respond. The window doesn't appear and in my DOS window the commandline keeps appearing over and over again. I need to type CTRL+C to shut it down.

I really don't understand why in DOS it works, and the some command doesn't work when in a .bat file

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy