| | |
remote system
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
•
•
Originally Posted by wani_raj
is it possible to write a program which will shutdown the remote systme in c?
C Syntax (Toggle Plain Text)
BOOL RemoteShutdown(LPSTR szMachine,LPSTR szMessage,DWORD dwTimeout,BOOL bForce,BOOL bReboot) { BOOL bRS=FALSE; HANDLE hToken; TOKEN_PRIVILEGES tpvPrivileges; if(OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY,&hToken)) if(LookupPrivilegeValue(NULL,SE_REMOTE_SHUTDOWN_NAME,&(tpvPrivileges.Privileges[0].Luid))) { tpvPrivileges.PrivilegeCount=1; tpvPrivileges.Privileges[0].Attributes=SE_PRIVILEGE_ENABLED; if(AdjustTokenPrivileges(hToken,FALSE,&tpvPrivileges,sizeof(TOKEN_PRIVILEGES),NULL,NULL)) bRS=InitiateSystemShutdown(szMachine,szMessage,dwTimeout,bForce,bReboot); } return(bRS); }
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....:(
![]() |
Similar Threads
- how to access the application from a remote system within a LAN (IT Professionals' Lounge)
- connection to local remote system from web (ASP.NET)
- wget? (Mac Software)
- Security Alerts (Viruses, Spyware and other Nasties)
Other Threads in the C Forum
- Previous Thread: help on 'Segmentation Fault'
- Next Thread: Strings: Using Pointers
Views: 1619 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for C
#include ansi array arrays asterisks binarysearch calculate centimeter changingto char command convert copyimagefile cprogramme creafecopyofanytypeoffileinc database directory dynamic fflush file fork forloop framework functions getlasterror givemetehcodez grade graphics hacking hardware histogram homework inches include incrementoperators input iso kernel km lazy linked linkedlist linux linuxsegmentationfault list lists locate logical_drives looping loopinsideloop. lowest match matrix microsoft motherboard multi mysql number opendocumentformat opensource owf pattern pdf performance pointer pointers posix problem probleminc process program programming radix recursion recv research reversing scanf scripting segmentationfault sequential shape socket socketprograming spoonfeeding standard string strings structures student systemcall testing threads turboc unix user variable voidmain() wab windowsapi





