Solved

shutdown problem

Posted on 2003-10-31
5
264 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Batch file output 20 76
c# combobox autocomplete behavior 6 92
ClickOnce Install - Shortcut Question 3 58
wordlen challenge 3 46
A short article about a problem I had getting the GPS LocationListener working.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

707 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now