944,093 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 1771
  • C RSS
Aug 1st, 2005
0

remote system

Expand Post »
is it possible to write a program which will shutdown the remote systme in c?
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
wani_raj is offline Offline
7 posts
since Jul 2005
Aug 1st, 2005
0

Re: remote system

Quote 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".
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
Sauce is offline Offline
55 posts
since Jul 2005
Aug 1st, 2005
0

Re: remote system

Quote 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.
Reputation Points: 12
Solved Threads: 4
Junior Poster
Alvein is offline Offline
104 posts
since Jul 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: help on 'Segmentation Fault'
Next Thread in C Forum Timeline: Strings: Using Pointers





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC