🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #9961

ShutDown WindowsXP Domain User

#9961
From: Alex Sarafian
Date: Tue, 01 Jun 2004 10:10
40 lines
2264 bytes
Hello.
I have wrtitten an application that performs custom schedulled shutdown of
the computer.
This application was written for my home WinXP where there is a single user
active. But now i'nm trying to use it on a winxp that is part of a domain.
The application want shutdown. None of the functions that temper with the
privilidges returns an error. It just doesn't shutdown.
Is there any possibility that the domain is not allowing the shutdown???

Here is the code

        HANDLE hToken;
        TOKEN_PRIVILEGES tkp;
        // Get a token for this process.
        if (!OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES |
TOKEN_QUERY, &hToken))
        {
            return 0;
        }

        // Get the LUID for the shutdown privilege.
        LookupPrivilegeValue(NULL,
SE_SHUTDOWN_NAME,&tkp.Privileges[0].Luid);
        tkp.PrivilegeCount = 1;  // one privilege to set
        tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;

        // Get the shutdown privilege for this process.
        AdjustTokenPrivileges(hToken, FALSE, &tkp,
0,(PTOKEN_PRIVILEGES)NULL, 0);
        // Cannot test the return value of AdjustTokenPrivileges.
        if (GetLastError() != ERROR_SUCCESS)
        {
            return 0;
        }
        // Shut down the system and force all applications to close.
        if (!ExitWindowsEx(EWX_POWEROFF | EWX_FORCE, 0))
            return 0;


Tanks for any answers
Technical Details
Message-ID: <40bc5626@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!controlnews3.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!t-online.de!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,5d80fe0793c2628d,start
X-Google-Attributes: gid10cc67,public
From: "Alex Sarafian" <demelene_gr@yahoo.gr>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: ShutDown WindowsXP Domain User
Date: Tue, 1 Jun 2004 13:10:58 +0300
Lines: 42
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 150.140.3.118
Message-ID: <40bc5626@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1086084646 150.140.3.118 (1 Jun 2004 03:10:46 -0700)
Path: arc1-ca.pugleaf.net!controlnews3.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!t-online.de!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail