WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Run Winbatch as a Service

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

XP SP2 Rebooting from Winbatch Service Failing


Question:

I have written a service that runs on Windows XP (in Netware 5 network) and at a predetermined time (1:00am Default), forces the computer to reboot, logs in using AutoAdminLogon and via “RunOnce” in the registry, launches another utility that applies any updates that may be needed and performs a final reboot ending up at the Novell login prompt.

The following code is the bit that performs the reboot:


DefUserID = "LocalAdministratorAccount"
DefAdmPW = “LocalAdminPassword”; decrypted from a file using RC4 Encryption Extender
RunWithLogon("Shutdown", "-r -t 00 -f", ".", @NORMAL, @NOWAIT, DefUserID, "", DefAdmPW,1)

This process has been in operation since October 2003 and has functioned flawlessly on several thousand computers across our corporation.

We are in the process of evaluating SP2 for XP and in doing so, the above code has stopped working with the following error: 08/07/04 16:00:16 WBT - UpdateSvc.exs 1932: WinExec: Function Failed

RunWithLogon("Shutdown", "-r -t 00 -f", ".", @NORMAL, @NOWAIT, DefUserID, "", DefAdmPW,1)
After clicking on the “Additonal Error Info” button the following message is displayed:
WinExec Error: Access is denied.
This error ONLY occurs when the service attempts the reboot. When this code is executed in the utility that runs from the RunOnce entry in the Registry, it works fine.

For debugging purposes, I added the following line:

Message(DefUserID, DefAdmPW)
immediately before the RunWithLogon line, in order to verify that I was using the correct ID and password. In all cases, the correct ID and password are being used.

Can anyone provide any enlightenment for the failure under XP SP2 and possible workaround?

Answer:

1) Where is "shutdown.exe" located at? Is it on the local hard drive or on a network share? If on a network share, is it a NetWare server or Windows server that hosts the share?

Also, what credentials is your service running under that it doesn't already have the privileges needed to reboot the workstation? I'm curious as to why RunWithLogon() needs to be used at that point.

2) You can reboot a workstation using an IntControl() function call within WinBatch. You shouldn't need to shell out to an external program.

3) Using the wntLsaPolSet() & wntLsaPolGet() functions, you can store user credentials in the registry [private data] in an encrypted form. That's just offered up as something for your information in case you didn't know you could do that.

User Reply:

Shutdown.exe is in c:\winnt\system32 (In the path statement), and as mentioned, this same bit of code works when submitted via a users ID, rather than as a service.

We were using Intcontrol(67,0,1,0,0), but found that an unacceptably large number of computers (about 15-20%) were hanging. Something wasn't being forced to shut down.

Basically, I ended up running Shutdown using the RunWithLogon command because all other options produced unacceptably consistent results.

As to credentials, I've never considered this to be a problem. The service has been installed using the LocalAdministrator account and has been working successfully for almost a year. I'll take a look at the wntLsaPolSet() & wntLsaPolGet() functions and see if this helps.

I'll post response as soon as I have something.

Answer:

Have you tried using the wntShutdown() function in the NT extender in place of the IntControl() function and in place of the external SHUTDOWN.EXE?

Also, if your service is running as Local System, then it should have carte-blanche access w/respect to privileges when calling wntShutdown().

User Reply:

This works!!! Thank you VERY much for your help,

More:

This article lists the problems that are fixed in Microsoft Windows XP Service Pack 2 (SP2). http://support.microsoft.com/default.aspx?scid=kb;en-us;811113

See Article number 814761...

http://support.microsoft.com/?kbid=814761

Question 2:

According to article W16677, isn't it possible to call external programs and functions within Windows XP SP2 and the RunWithLogon-command ?

Answer:

NOTE:
SP2 changed how Winbatch has to handle the situation, and the required Winbatch changes show up in the current version (2005C). Older versions of Winbatch have issues with RunWithLogon when used from a service under SP2.
Article ID:   W16677
File Created: 2005:10:12:10:16:28
Last Updated: 2005:10:12:10:16:28