Solved

shutdown problem

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
python question 5 69
Currency Conversion? 1 73
Adoquery sql  left join does not work 25 81
Programatically extract date from website 8 68
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
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…
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 …

863 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

21 Experts available now in Live!

Get 1:1 Help Now