Jump to content

Welcome to MSFN Forum
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account


Photo

NT4 - Shuting down and restarting the server

- - - - -

  • Please log in to reply
44 replies to this topic

#1
am12348

am12348

    Newbie

  • Member
  • 21 posts
  • OS:none specified
  • Country: Country Flag
Hello everybody,

I would like to if there is a statement I can write in the command window that shuts down the server and restarts it.

I was told that I can use the following command. However, when I tried Inothing happened

Under c:\winnt\system32

rundll32.exe shutdown /1 /y /r


My purpose is to add the cmd to a batch file which is scheduled on a certain time

Thank you in advance,
Amos


How to remove advertisement from MSFN

#2
angmor

angmor
  • Member
  • 7 posts
  • OS:none specified
  • Country: Country Flag
Different versions of Windows use different parameters for shutdown.exe
I don't have the NT4 RK shutdown.exe easily accessible but I think the parameters may be the same as NT4

from the W2K resource kit, shutdown.exe:
shutdown /l /r /y /c

/l
Specifies a local shutdown. (note that the parameter is the lower case letter L)
/r
Restart the computer specifed after shutdown.
/y
Answers questions with "yes".
/c
Forces running applications to close. Caution
If you use the /c parameter, Windows 2000 ignores the application's option to save data that might have changed. You will see no File Save dialog box, because Windows 2000 will force the application to close. This will result in a loss of all data not previously saved.

Other parameters:
\\computername
Specifies the remote computer to shut down. If no name is given but the tool is started with any of the other options, the local computer name will be used.
/a
Quits a system shutdown. This can only be done during the timeout period. If this switch is used, all others are ignored.
/t:xx "msg"
Sets the timer for system shutdown in xx seconds. The default is 20 seconds.
"msg"
Specifies an additional message with a maximum of 127 characters, surrounded by quotation marks.
/? (or shutdown without parameters)
display help.

#3
jaclaz

jaclaz

    The Finder

  • Developer
  • 14,289 posts
  • OS:none specified
  • Country: Country Flag

I would like to if there is a statement I can write in the command window that shuts down the server and restarts it.

Here:

Reboot Windows NT
(without the need to use the Resource Kit)


http://www.robvander...mb_rebootnt.php

jaclaz

#4
am12348

am12348

    Newbie

  • Member
  • 21 posts
  • OS:none specified
  • Country: Country Flag
Hello everybody,

For a certain reason I want to shut down and restart the NT4 at a certain hour on specific dates.

I wrote in the command screen:

at 07:15 /every:Su,M,T,W,TH,F restartNT4

restartNT4 is a private batch file. I have not found an appropriate command in NT4, that does
shut down and restart.

When I types the statement at, I've seen this command in the list.

However, when the specified time comes in the appropriate days in week, nothing happens.

Does anyone have an idea, what is wrong.

When I type the command-the name of the batch file regularly - The server shuts down and
restarts.


Thank you,
Amos

#5
am12348

am12348

    Newbie

  • Member
  • 21 posts
  • OS:none specified
  • Country: Country Flag
Thank you for your replies they helped me

Edited by am12348, 06 January 2013 - 02:45 PM.


#6
allen2

allen2

    Not really Newbie

  • Member
  • PipPipPipPipPipPipPip
  • 1,812 posts
You might need to put the full path name of the batch.
You could also use the psshutdown command from the pstools with the right user.

Edited by allen2, 06 January 2013 - 03:01 PM.


#7
am12348

am12348

    Newbie

  • Member
  • 21 posts
  • OS:none specified
  • Country: Country Flag
]Hello,

First of all thank you.

Secondly, I've specified the scheduled command in a full path. However the situation
is the same - the "at " command does not take effect. I've even put the full command in
quotes.

However, if I specify the "interactive" parameter, the "at" then stops at the scheduled
time and waits, the user to put something.

I want to use the "interactive" parameter to solve my problem. Therefore I would like to
know, if there a way to put an additional parameter besides the "interactive", that tells the
system, that if there is not any response from the user for a certain time, the command
associated to the "at" is done.

Thank you,
Amos

#8
am12348

am12348

    Newbie

  • Member
  • 21 posts
  • OS:none specified
  • Country: Country Flag
Hello,

As I've written before, I've met a problem in "at" cpmmand in our NT4. The command
does not take effect when the scheduled time comes.I've specified the full path, I've
put the command in quotes. It didn't help.

However, if I specify the "interactive" parameter, the "at" then stops at the scheduled
time and waits the user to put something.

ThereforeI want to try to use the "interactive" parameter to solve my problem, but a
user has not to be near the server at that time.

Is there an additional parameter besides the "interactive" parameter "number of seconds
to wait" "so that the server executess the command in "at" automatically if no one gives
any response?


Thank you for your answers,
Amos

#9
am12348

am12348

    Newbie

  • Member
  • 21 posts
  • OS:none specified
  • Country: Country Flag
Hello,

As I've specified the previous topocs I've a problem in "at" comans - The associated command
does not take effect when the schedule time cones, even though the schediler service has
been starsed.

I've heard , that in order that "at" will take effect , an additional service besides the scheduler
task has to be started by an administrator.

Does anyone know the name of that setvice?

Thank you,
Amos

#10
am12348

am12348

    Newbie

  • Member
  • 21 posts
  • OS:none specified
  • Country: Country Flag
Hello,

Thank to anyone that will help me to overcome this problem:

I've write a batch file that shuts down and restarts the NT server.

I've put it in the C: drive in the NT.

When I activate the batch in the cmd screen, it shuts down and restarts
the server as espected.

I want to activate the batch at a specific time. Therefore I try to use the
function "at":

I write in the cmd screen:
at 07:00 /every:Su,M,T,W,TH,F c:\temp\restart.bat

When the time comes, the server sounds a "beep", but it seems that the batch is not activated

When I write in the cmd screen
at 07:00 /interactive /every:Su,M,T,W,TH,F c:\temp\restart.bat
When the time comes, the server displays a message about istallation error. The batch
is not activated.

What is wrong with what I've written?

Is there an alternative way, any function, to schedule the batch file?

Thank you
Amos

#11
submix8c

submix8c

    Inconceivable!

  • Patrons
  • 4,263 posts
  • OS:none specified
  • Country: Country Flag
Hmmm -
http://www.computing...-nt-/14540.html
Get it here (maybe)
http://www.hpcfactor...s/msie/ie55sp2/
Or find links here (better)
http://www.mdgx.com/ietoy.htm#IE55

Not sure if using "Task Scheduler" will work out better than "AT" or not.

edit - It appears that using a BAT directly may not work? Look at this as well
http://computerplumb...scheduled-task/

HTH

Edited by submix8c, 26 January 2013 - 03:33 PM.

Someday the tyrants will be unthroned... Jason "Jay" Chasteen; RIP, bro!

Posted Image


#12
bphlpt

bphlpt

    MSFN Addict

  • Member
  • PipPipPipPipPipPipPip
  • 1,797 posts
  • OS:none specified
  • Country: Country Flag
I noticed that it says that the "schedule" service must be running for the "AT" command to work correctly. Is your "schedule" service running?

Cheers and Regards

Posted Image


#13
am12348

am12348

    Newbie

  • Member
  • 21 posts
  • OS:none specified
  • Country: Country Flag
Hello,

As far as I've checked, the "schedule" service is running.In the NT4 server, I've gone to the control panel and
under "services" I've seen that "schedule" is active

#14
jaclaz

jaclaz

    The Finder

  • Developer
  • 14,289 posts
  • OS:none specified
  • Country: Country Flag
Post the contents of the actual .bat (which BTW should really be a .cmd)

Here there are some good tips on what to add to the batch to troubleshoot/debug:
http://www.robvanderwoude.com/ntat.php

jaclaz

#15
am12348

am12348

    Newbie

  • Member
  • 21 posts
  • OS:none specified
  • Country: Country Flag
Hello,

Here there is the content of the batch I use:


@ECHO OFF & cd/d %temp% & echo [version] > {out}.inf
(set inf=InstallHinfSection DefaultInstall)
echo signature=$chicago$ >> {out}.inf
echo [defaultinstall] >> {out}.inf
rundll32 setupapi,%inf% 1 %temp%\{out}.inf
del {out}.inf

If I activate the batch without "at" , it is working as expected.

However if I put in in "at", when time comes, a beep is sound
and the batch does not work

I write the "at" as follows:

at 07:00 /interactive /every:Su,M,T,W,TH,F c:\winnt\system32\cmd.exe /q /c c:\temp\restart.bat

#16
am12348

am12348

    Newbie

  • Member
  • 21 posts
  • OS:none specified
  • Country: Country Flag
Hello,

As far as I know, there is not "Schedulrd Task" under Control Panel"

Following to the replies in the forum, I've done the following:
- I've written a batch file, which shuts down the NT4 server and restarts it
- I've verified that the schedule service is active
- I've define a new "at" activity in such way:
at 07:00 /every:Su,M,T,W,TH,F c:\winnt\system32\cmd.exe /q /c c:\temp\restart.bat

When I write "at": in the command prompt, I see a new id with the one I've defined

Now, when the time comes,I hear a beep but the at does not take efffect
I've written the same, but with the parameter interactive

at 07:00 /interactive /every:Su,M,T,W,TH,F c:\winnt\system32\cmd.exe /q /c c:\temp\restart.bat

When the time comes, the server displays a message about istallation error. The batch
is not activated.

When I write another activity for example "notepad"
at 07:00 /interactive /every:Su,M,T,W,TH,F notepad
The notepad window is displayed, when the time comes

If I write simply "c:\temp\restart.bat", the batch works as expected - It shuts down the server and restarts it

Does anyone have an idea what can I do, is there an alternative way, any function, to schedule the batch?


Is there an alternative way, any function, to schedule the batch file?


Thank you in advance,
Amos

#17
jaclaz

jaclaz

    The Finder

  • Developer
  • 14,289 posts
  • OS:none specified
  • Country: Country Flag
READ the given link.

Add a PAUSE command to the end of any batch file to be sceduled, and REM out the initial @ECHO OFF line, so you'll be able to see the "flow" of the batch file -- what commands does it execute, does it jump to any labels, etc.
Just schedule CMD.EXE to be started, using AT.EXE's /INTERACTIVE switch to make the CMD prompt visible
Now execute the command in the resulting CMD prompt and see if the access rights are sufficient for the task you intend to schedule
Check the current directory; is it the same directory you used for testing the command?
It is best to use fully specified paths instead of relying on PATH variables that may change every now and then or even be different for different user IDs
Check if you can access remote systems, if that's necessary for the task to be scheduled; many scheduled COPY commands to remote systems fail because the SYSTEM account cannot access remote network drives
Check if the necessary drive mappings are available in this CMD prompt
Check the environment variables; are they identical to your own environment variables?
Remember, this CMD prompt is the exact environment that your scheduled command will be using


It is possible that there are access rights issue (IMHO the most likely, but cannot really say).
It could be an issue when writing the temporary "out" file or when actually executing it through rundll32 setupapi.
Do exactly the steps listed above, and report what happens/which step fails.

At first sight there is nothing "wrong" in the batch, I would personally write it slightly differently:
@ECHO OFF
PUSHD %temp%

set inf=InstallHinfSection DefaultInstall
::SET
::PAUSE

(
echo [version]
echo signature=$chicago$
echo [defaultinstall]
)>{out}.inf
:: TYPE {out}.inf
::PAUSE
rundll32 setupapi,%inf% 1 %temp%\{out}.inf
::PAUSE
del {out}.inf
POPD
but it shouldn't make a difference (to test remove the :: in front of the lines to pause and show what is happening).


jaclaz

P.S: : I am not too sure that grouping with brackets is supported in NT 4, if it doesn't work revert to plainer:

echo [version]>{out}.inf
echo signature=$chicago$>>{out}.inf
echo [defaultinstall]>>{out}.inf

Edited by jaclaz, 31 January 2013 - 02:08 PM.


#18
Tripredacus

Tripredacus

    K-Mart-ian Legend

  • Super Moderator
  • 9,769 posts
  • OS:Server 2012
  • Country: Country Flag

Donator

Post #7 is from a thread merge.
MSFN RULES | GimageX HTA for PE 3-5 | lol probloms
msfn2_zpsc37c7153.jpg

#19
allen2

allen2

    Not really Newbie

  • Member
  • PipPipPipPipPipPipPip
  • 1,812 posts
Scheduled tasks service will be installed on nt4 after upgrading Internet explorer to version 6 sp1 and this might solve problems with at tasks not working properly.

#20
submix8c

submix8c

    Inconceivable!

  • Patrons
  • 4,263 posts
  • OS:none specified
  • Country: Country Flag
Post #7 is a Thread Merge (see post #9)
Post #10 says IE6SP1 (should work fine)
Post #2 says Minimum/Recommended IE5.5SP2 (see link)

Install one or the other. Task Scheduler will appear in Control Panel.
Also see LAST link in Post #2 for "How To" in Task Scheduler. A slight "trick". Fairly simple. ;)

When I write another activity for example "notepad"

It's because it's a PROGRAM and not a BAT/CMD. You have to start CMD.EXE and cause IT to execute the BAT/CMD file (again, see last link Post #2 indicating the Problem and Workaround). Also note Post #5 and Post #8 suggesting CALLING the Functions via CMD.EXE (same deal-io).

In fact this scenario has me confused.

I've write a batch file that shuts down and restarts the NT server.

OK...

Here there is the content of the batch I use:

(reference also Post #8). Is the (lacking contents of the) INF file supposed to Shut Down/Beep/Restart the OS? Guessing so(?), but unsure about BEEP unless that's from the PC starting up during POST?
Another reference to RUNDLL32 also from Rob -
http://www.robvander....com/rundll.php
AAAAAND the INF/BAT in question is ALSO referenced by Rob (scroll down) -
http://www.robvander...om/shutdown.php

Your PROBLEM is putting the INF into a BAT/CMD and causing it to SCHEDULE.
Combine the Partial Solutions listed.
1 - Install IE5.5SP2/IE6SP1 (see references)
2 - Create the BAT file (see refrences)
3 - Scheduler the CMD in Task Scheduler to Run the BAT (see references)
Done!
Note: I'm really unsure if you will need some kind of Delay somewhere to allow for Scheduled CMD Exit. You should PROBABLY use "START /WAIT xxxx.BAT"(?). Maybe an "EXIT" need put in the end of the BAT(?).
http://ss64.com/nt/cmd.html

cmd.exe /q /c

...the TARGET being START(?)...
http://www.robvander...com/ntstart.php

Edited by submix8c, 01 February 2013 - 07:34 AM.

Someday the tyrants will be unthroned... Jason "Jay" Chasteen; RIP, bro!

Posted Image


#21
jaclaz

jaclaz

    The Finder

  • Developer
  • 14,289 posts
  • OS:none specified
  • Country: Country Flag
Hmmm, I would rather troubleshoot and solve the issue at hand with AT rather than have IE6 SP1 in order to have Task Scheduler.
There is not one reason in the world why plain AT should not work, AFAIK.

There is more than one way to skin a cat, most of them without any need to have Internet Explorer on NT 4.

In my (perverted) mind installing IE on NT4 and upgrading it to IE6 sounds like a complete failure at solving the problem and thus shooting a fly with a cannon.

If the issue is not resolved "simply", I would rather try a third party tool such as (example) nircmd:
http://www.nirsoft.n...ils/nircmd.html



jaclaz

#22
submix8c

submix8c

    Inconceivable!

  • Patrons
  • 4,263 posts
  • OS:none specified
  • Country: Country Flag
Maybe scheduling SHUTDOWN instead? :unsure:
http://www.robvander...om/shutdown.php

NT4+RK | SHUTDOWN /L /R /T:0 /Y | Effect=Reboot | Remarks=Immediate shutdown & reboot

Reference here -
http://ss64.com/nt/shutdown.html
"Random" site (I like that term now!) giving the MS Link and some info -
http://smallvoid.com...winnt4sp4st.htm
Another "random site" (google cache)

File is not on MS anymore (even with Wayback). But Google
"sp4rk_i386.exe"
Inside the EXE is a CAB and inside it is "NETMGMT_NETADMIN_shutdown.exe".

You could ALSO maybe try the PSSHUTDOWN (robvanderwoude link above lists it).

Wouldn't either one of these be more "direct"? :unsure:

Someday the tyrants will be unthroned... Jason "Jay" Chasteen; RIP, bro!

Posted Image


#23
allen2

allen2

    Not really Newbie

  • Member
  • PipPipPipPipPipPipPip
  • 1,812 posts

You could ALSO maybe try the PSSHUTDOWN (robvanderwoude link above lists it).

Wouldn't either one of these be more "direct"? :unsure:

That what i already proposed in his previous thread....

Edited by allen2, 02 February 2013 - 01:54 PM.


#24
submix8c

submix8c

    Inconceivable!

  • Patrons
  • 4,263 posts
  • OS:none specified
  • Country: Country Flag
Ahhh! The "Thread Merge"...

Someday the tyrants will be unthroned... Jason "Jay" Chasteen; RIP, bro!

Posted Image


#25
am12348

am12348

    Newbie

  • Member
  • 21 posts
  • OS:none specified
  • Country: Country Flag
Hello,

First of all thank you for your useful posts, referinfg to my problem in at command.

I've changed my batch file, that shuts dowwn and restarts NT4 server according to
Jaclaz's post. I've added "pauses" to some places in the batch and configured the
"at" command to run the batch interactively. run the batch interactively step by step.
The pauses have helped me to find out what is wrong wuth the batch. I've fixed the
problems and now, when the time configured in "at| command comes, the batch is
actuvared and is working properly.

Ther is still a one little problem. I use to lock the server when I don't use it and
ublock it by ty[ing a password. When the server is locked, the batch file doesn't
work properly, when the configured time comes. In my logs, I can see that the
batch has been activated, but it haven't worked properly.

Can be any problem in activation of scheduled batches, when the server is locked?
What can I do to overcome this problrm?

Thank you for your useful help,
Amos




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users



How to remove advertisement from MSFN