Article View: borland.public.cppbuilder.nativeapi
Article #15295EGADS!!!!
From: James A Beggs
Date: Tue, 15 Jul 2003 21:09
Date: Tue, 15 Jul 2003 21:09
40 lines
2160 bytes
2160 bytes
I wrote a program for rebooting a windows server 2000 machine. It had to do
some other things first - shut down three services, delete all files from a
specific folder - but then its to reboot.
It works just great on my windows xp laptop. Not a problem.
The windows 2k server, here at work.... hehe....
It wont come back on.
:(
The code is posted below. Any ideas where I screwed up - or if this is just
maybe a coincidence?
Thanks!
[code]
DllExport bool ShutDownWindows()
{
HANDLE hToken;
TOKEN_PRIVILEGES MyToken;
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES |
TOKEN_QUERY, &hToken))
return false;
LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME,
&MyToken.Privileges[0].Luid);
MyToken.PrivilegeCount = 1;
MyToken.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges(hToken, false, &MyToken, 0,
(PTOKEN_PRIVILEGES)NULL, 0);
return (ExitWindowsEx(EWX_REBOOT | EWX_FORCE, 0));
}
[/code]
--
James A Beggs
Manager of Product Development
American Quarter Horse Association
Technical Details
Message-ID:
<3f146c0c$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-04!sn-xit-06!sn-xit-09!supernews.com!216.170.153.135.MISMATCH!tdsnet-transit!newspeer.tds.net!205.215.62.125.MISMATCH!in.100proofnews.com!in.100proofnews.com!nntp.infostrada.it!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,4279daef20036543,start X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-07-15 14:12:34 PST From: "James A Beggs" <jbeggs@aqha.org> Newsgroups: borland.public.cppbuilder.nativeapi Subject: EGADS!!!! Date: Tue, 15 Jul 2003 16:09:56 -0500 Lines: 42 Organization: American Quarter Horse Association X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 NNTP-Posting-Host: 12.19.120.242 Message-ID: <3f146c0c$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1058302988 12.19.120.242 (15 Jul 2003 14:03:08 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-04!sn-xit-06!sn-xit-09!supernews.com!216.170.153.135.MISMATCH!tdsnet-transit!newspeer.tds.net!205.215.62.125.MISMATCH!in.100proofnews.com!in.100proofnews.com!nntp.infostrada.it!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail