Page 1 of 1 1
Topic Options
#152765 - 2005-12-02 07:47 PM Restart in a Startup Script
sixdoubleo Offline
Starting to like KiXtart

Registered: 2004-02-06
Posts: 118
Loc: California, US
Does anybody have a working solution for restarting within a startup script? I have tried the following:

SHUTDOWN.EXE (from NT/2000 Resource Kit)
shutdown /L /R /T:1 /Y

shutdown.exe (comes with XP)
shutdown -r -t 1

psshutdown.exe (SysInternals)
psshutdown -r -t 1

My code looks like this:

Code:

If $bRebootRequired = True
;$RunCommand = "\\SCONET\Netlogon\Util\shutdown /L /R /T:1 /Y"
$RunCommand = "\\SCONET\Netlogon\Util\psshutdown -r -t 1"
RUN $RunCommand
EndIf



This all works while logged in, but not during startup. They just do nothing during the startup.

Doing some searching on this topic it seems that other folks have had this problem as well. One popular solution was to create an SMS object that reboots. Not really an option for me. I suppose I could create an MSI that does nothing and reboots...but that seems a little excessive.

Anybody have this working?

Top
#152766 - 2005-12-02 07:58 PM Re: Restart in a Startup Script
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
you don't want to use the integral shutdown command in kix?

http://www.scriptlogic.com/Kixtart/htmlhelp/Functions/shutdown.htm
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#152767 - 2005-12-02 08:21 PM Re: Restart in a Startup Script
sixdoubleo Offline
Starting to like KiXtart

Registered: 2004-02-06
Posts: 118
Loc: California, US
Oops. I forgot to add that to the list of things I've tried.

$rc = Shutdown("","",0,1,1)

It does nothing. Login and run it manually and it works fine.

Top
#152768 - 2005-12-02 08:27 PM Re: Restart in a Startup Script
sixdoubleo Offline
Starting to like KiXtart

Registered: 2004-02-06
Posts: 118
Loc: California, US
Could it be because all these methods perform the user.exe,ExitWindows function and user.exe isn't loaded??

In that the user can simply press ctrl-alt-del and select Shutdown|Restart without logging in, I assume there is a way to do this.

Top
#152769 - 2005-12-02 08:39 PM Re: Restart in a Startup Script
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Have you tried WMI?
Top
#152770 - 2005-12-02 08:39 PM Re: Restart in a Startup Script
sixdoubleo Offline
Starting to like KiXtart

Registered: 2004-02-06
Posts: 118
Loc: California, US
Update...the command:

devcon reboot

works!

So why is this? I assume it has something to do with the fact that Kix's Shutdown() function, shutdown.exe, psshutdown.exe and others, simply perform a standard hook into user.exe which isn't available???

devcon reboot does something different.

Devcon:
http://support.microsoft.com/?kbid=311272


Edited by sixdoubleo (2005-12-02 08:39 PM)

Top
#152771 - 2005-12-02 08:48 PM Re: Restart in a Startup Script
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Remember talking around this shutdown issue in the past. Might want to read this article

You Cannot Schedule a Windows XP-Based Computer to Shut Down and Restart by Using the AT Command with Shutdown.exe

While not directly related, just wondering if theres something in there that might twig a thought.

Here is the original thread ...

Ability to restart XP when no user is logged on

-Shawn

Top
#152772 - 2005-12-02 09:04 PM Re: Restart in a Startup Script
sixdoubleo Offline
Starting to like KiXtart

Registered: 2004-02-06
Posts: 118
Loc: California, US
Quote:

Remember talking around this shutdown issue in the past. Might want to read this article

You Cannot Schedule a Windows XP-Based Computer to Shut Down and Restart by Using the AT Command with Shutdown.exe

While not directly related, just wondering if theres something in there that might twig a thought.

Here is the original thread ...

Ability to restart XP when no user is logged on

-Shawn




Thanks Shawn. It does appear that we're dealing with a similar issue. Startup Scripts run as the system account (as does AT) and as such would be limited by the same issue I'd think. The KB article you reference claims that the latest XP service pack corrects this issue. Not sure about that one. These are all SP2 machines.

Anyway, what ended up becoming of that? Like I said above, devcon reboot does work. I am happy using that for now, but would prefer a more native method.


Edited by sixdoubleo (2005-12-02 09:05 PM)

Top
#152773 - 2005-12-02 09:05 PM Re: Restart in a Startup Script
sixdoubleo Offline
Starting to like KiXtart

Registered: 2004-02-06
Posts: 118
Loc: California, US
Quote:

Have you tried WMI?




Yes..

The following works while logged in, does not work in startup.
Code:

$rc = WMIRestart()
Function WMIRestart()
Dim $wmi, $System, $WQL, $colSystem

$wmi = GetObject("winmgmts:{impersonationLevel=impersonate,(Shutdown)}!\\" + @WKSTA + "\root\cimv2")

$WQL = "Select * From Win32_OperatingSystem"
$colSystem = $wmi.ExecQuery($WQL)

For Each $System In $colSystem
$System.Win32ShutDown(6)
Next
EndFunction


Top
#152774 - 2005-12-05 09:39 AM Re: Restart in a Startup Script
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
I've had a number of problems where the shutdown fails and the error is something like "computer not ready" or "not in a suitable state".

A very simple example is where the username/password login dialogue is active, but there have been other causes. I imagine that during startup it is pretty likely that the machine will be in various states when Windows will reject shutdown requests because they are potentially dangerous.

You could put the shutdown in a simple loop, and if it errors wait a period (30 seconds?) and then try again. After a 10 or 15 minutes of retries give it up as a bad job.

Top
#152775 - 2005-12-05 11:21 AM Re: Restart in a Startup Script
masken Offline
MM club member
*****

Registered: 2000-11-27
Posts: 1222
Loc: Gothenburg, Sweden
Remember that a startup-script runs under the LOCAL system account. If you put utilities on a network server, make sure that the computer account has access to them.
_________________________
The tart is out there

Top
#152776 - 2005-12-05 06:25 PM Re: Restart in a Startup Script
sixdoubleo Offline
Starting to like KiXtart

Registered: 2004-02-06
Posts: 118
Loc: California, US
Yeah, not the problem but thanks for the reminder. Permissions are all in order.

What we've got here is a legitmate bug/feature/limitation with XP as indicated in the link posted by Shawn. As I stated, I've started using the devcon utility and we're rebooting nicely.

Top
#152777 - 2005-12-05 06:28 PM Re: Restart in a Startup Script
sixdoubleo Offline
Starting to like KiXtart

Registered: 2004-02-06
Posts: 118
Loc: California, US
Quote:

I've had a number of problems where the shutdown fails and the error is something like "computer not ready" or "not in a suitable state".

A very simple example is where the username/password login dialogue is active, but there have been other causes. I imagine that during startup it is pretty likely that the machine will be in various states when Windows will reject shutdown requests because they are potentially dangerous.

You could put the shutdown in a simple loop, and if it errors wait a period (30 seconds?) and then try again. After a 10 or 15 minutes of retries give it up as a bad job.




I'm rebooting after doing a bunch of activity (installing updates) so that isn't the case here. The system is deifnitely stable at that point.

Judging by the KB article from Microsoft, they are fixing this with the next SP. 3? It has one of those notices that a fix is available but you have to call them. I never do that as it's usually a hassle. I have a workaround for now so I think I'll just wait until MS fixes the issue. Once a new shutdown.exe is released (which, since it hooks off of user.exe,ExitWindows I assume Kix's Shutdown and psshutdown.exe would be fixed in the process?) I'll switch to a more native restart mechanism.


Edited by sixdoubleo (2005-12-05 06:33 PM)

Top
#152778 - 2005-12-06 06:13 AM Re: Restart in a Startup Script
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
what's your workaround now?
killing smss.exe?
_________________________
!

download KiXnet

Top
Page 1 of 1 1


Moderator:  Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Glenn Barnas) and 955 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.067 seconds in which 0.026 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org