remote system

Reply

Join Date: Jul 2005
Posts: 7
Reputation: wani_raj is an unknown quantity at this point 
Solved Threads: 0
wani_raj wani_raj is offline Offline
Newbie Poster

remote system

 
0
  #1
Aug 1st, 2005
is it possible to write a program which will shutdown the remote systme in c?
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 55
Reputation: Sauce is an unknown quantity at this point 
Solved Threads: 0
Sauce Sauce is offline Offline
Junior Poster in Training

Re: remote system

 
0
  #2
Aug 1st, 2005
Originally Posted by wani_raj
is it possible to write a program which will shutdown the remote systme in c?
Of course its possible. Depends on what way you want to do it and if you have access to install an application on the before mentioned "remote system".
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 104
Reputation: Alvein is an unknown quantity at this point 
Solved Threads: 4
Alvein's Avatar
Alvein Alvein is offline Offline
Junior Poster

Re: remote system

 
0
  #3
Aug 1st, 2005
Originally Posted by wani_raj
is it possible to write a program which will shutdown the remote systme in c?
Please try,

  1. BOOL RemoteShutdown(LPSTR szMachine,LPSTR szMessage,DWORD dwTimeout,BOOL bForce,BOOL bReboot) {
  2. BOOL bRS=FALSE;
  3. HANDLE hToken;
  4. TOKEN_PRIVILEGES tpvPrivileges;
  5. if(OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY,&hToken))
  6. if(LookupPrivilegeValue(NULL,SE_REMOTE_SHUTDOWN_NAME,&(tpvPrivileges.Privileges[0].Luid))) {
  7. tpvPrivileges.PrivilegeCount=1;
  8. tpvPrivileges.Privileges[0].Attributes=SE_PRIVILEGE_ENABLED;
  9. if(AdjustTokenPrivileges(hToken,FALSE,&tpvPrivileges,sizeof(TOKEN_PRIVILEGES),NULL,NULL))
  10. bRS=InitiateSystemShutdown(szMachine,szMessage,dwTimeout,bForce,bReboot);
  11. }
  12. return(bRS);
  13. }

Tested locally. I Don't have a network to try a working case.

szMachine: either name or IP should work.
szMessage*: some blah's for remote user to be aware of your action.
dwTimeout*: how many seconds to show your blah's.
bForce: close all applications with no confirmation.
bReboot: follow shutdown with a restart.

*(NULL,0): inmediate shutdown.

RemoteShutdown() returns TRUE on success.
Damn it, I still dream of her....:(
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC