Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Force ShutDown and Restart
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00143339
Message ID:
00145940
Views:
26
>Well, it doesn't work in this raw form - I'll have to investigate how to modify the SE_SHUTDOWN_NAME privilege.

You'll need to ensure that the user is either a member of Administrators, or has had the privilege specifically granted to them in User Administrator. There are ways of altering your privilege mask by impersonation (see the Win32 API guides) but I've never used impersonation anywhere but in a Service, and never from VFP.

Your best bet will be to simply adjust the account privilege sets outside of your app so that the ExitWindows() call will act on the request.

If an interactive shutdown is an option, and you've installed Windows Scripting Host on all systems involved, you could also look at using the ExitWindows method of the Wscript.Shell object.

>
>>>I could have sworn I saw a KB article around here on how to force an NT system to shut down and restart.
>>>
>>>I have an application that runs 24x7, and I'm experiencing odd troubles with it. I suspect a memory leak, and I just want to have the app shut down and restart WinNT every morning at 3:00 or something.
>>>
>>>Other apps will be running, but I suspect they will respond to the Windows shutdown message.
>>>
>>Hi Michael,
>>
>>I don't know if this'll do it on NT, but try the following:
>>#DEFINE EWX_REBOOT   2
>>DECLARE SHORT ExitWindowsEx IN Win32API;
>>  SHORT uFlags, INTEGER dwReserved
>>= ExitWindowsEx(EWX_REBOOT, 0)
>>According to the documentation on NT, "The calling process must have the SE_SHUTDOWN_NAME privilege....To shut down or restart the system, the calling process must use the AdjustTokenPrivileges function to enable the SE_SHUTDOWN_NAME privilege."
>>
>>hth,
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Reply
Map
View

Click here to load this message in the networking platform