is it possible to write a program which will shutdown the remote systme in c?
wani_raj
0
Newbie Poster
Recommended Answers
Jump to Postis it possible to write a program which will shutdown the remote systme in c?
Please try,
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 …
All 2 Replies
Reply to this topic
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.