Solved

shutdown problem

Posted on 2003-10-31
5
268 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

A short article about a problem I had getting the GPS LocationListener working.
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

696 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