Solved

shutdown problem

Posted on 2003-10-31
5
267 Views
Last Modified: 2008-02-26
HANDLE hToken;
       TOKEN_PRIVILEGES TokenPrivileges;
       OpenProcessToken( GetCurrentProcess(),
              TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken ) ;
       LookupPrivilegeValue( NULL, SE_REMOTE_SHUTDOWN_NAME, &(TokenPrivileges.Privileges[0].Luid));
       TokenPrivileges.PrivilegeCount           = 1;
       TokenPrivileges.Privileges[0].Attributes = 2;
       AdjustTokenPrivileges( hToken, FALSE, &TokenPrivileges,
                     sizeof(TOKEN_PRIVILEGES), NULL, NULL );
       if(!InitiateSystemShutdown(
              lpMachineName,  // name of computer to shut down
              lpMessage,      // address of message to display
              dwTimeout,       // time to display dialog box
              bForceAppsClosed, // force applications with unsaved  
              bRebootAfterShutdown ))
       {
              return GetLastError();
       }
       
the above code gives errror as acces denied , cause i dont have administrator privilage on remote machine
how do i go about it.
kiran
0
Comment
Question by:kirannapit
  • 2
5 Comments
 
LVL 9

Accepted Solution

by:
bhagyesht earned 75 total points
ID: 9656652
first get access to the machine by firing a
ShellExecute (NULL, "open","net.exe" , "\\<computername> /user:Administrator <admin password>", NULL, SW_SHOWNORMAL);

after this call your function to shutdown the computer.

kiran: you have one more question open which caters to the same problem. you could have asked this there itself and increased the points.
0
 
LVL 9

Expert Comment

by:bhagyesht
ID: 9656661
oops make that 2 more open questions.

1 10/31/2003 75 shutdown problem  Unlocked Programming
2 10/30/2003 75 remote shutdown  Unlocked Programming
3 10/29/2003 75 Remote shutdown using API  Unlocked Programming
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is an explanation of a simple data model to help parse a JSON feed
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question