?
Solved

shutdown problem

Posted on 2003-10-31
5
Medium Priority
?
270 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 300 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

Industry Leaders: 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

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Six Sigma Control Plans

764 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