Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Causing reboot
Message
From
03/07/1999 16:49:18
 
 
To
03/07/1999 14:56:16
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Title:
Miscellaneous
Thread ID:
00237227
Message ID:
00237246
Views:
12
>This looks like it was I had in mind but I can't seem to make it work. Where do I place this code? I tried putting it in a stand-alone prg and doing that, but nothing happens.
>

If it's going to work at all, it doesn't much matter where it is in code. Under Win9x, there must be a current window for the application; ExitWindowsEx() doesn't work from a console application. Under NT, without the necessary permissions, the ExitWindowsEx may either do nothing att all, or may cause the current user to be logged out. You can find the detailed documentation for ExitWindowsEx in the MSDN documentation for the Platform SDK; if you don't have an MSDN subscriptiuon (or a copy as provided with a product like Visual Studio 6 Enterprise) you can access the Platform SDK documentation on-line through MSDN Online (msdn.microsoft.com/developer).

>
>>>Would someone please describe in some detail a straight forward way of causing NT Server to reboot from within a VFP 5 .app?
>>
>>It can be done with a simple API call, however, being able to do it is not necessarily trivial, because the application may not be running with the needed privileges that would allow you to do more than log out the current user from NT. Assuming that the user has adequate privileges, the ExitWindowEx() API call can force a restart of NT Server, however, in addition to the issue of required privileges, there's also the issue of how to log ion with no user (or perhaps a user who doesn't have a valid account on the NT Server) after restart. While an automatic login can be set up using a couple of registry entries, this basically violates the security of the NT Server machine, since the registry values could be read by a less-privileged user.
>>
>>This also assumes that you're trying to reset the machine you're running the application on; remote reboots are considerably more complex.
>>
>>
DECLARE INTEGER ExitWindowsEx IN WIN32API ;
>>   INTEGER uFLags, ;
>>   INTEGER dwReserved
>>#DEFINE EWX_REBOOT 2
>>#DEFINE EWX_FORCE  4
>>=ExitWindowsEx(EWX_REBOOT + EWX_FORCE, 0)
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
Next
Reply
Map
View

Click here to load this message in the networking platform