View Full Version : Mi aiutate? shutdown pc da file exe
Voglio creare un file eseguibile (.exe o .bat) per spegnere il pc. Che istruzione devo scrivere? devo usare l'edit dal prompt dos vero?
Grazie per i consigli.
Se hai un OS di base NT devi fare un EXE, in che linguaggio ti server?
Hai qlc preferenza, altrimenti io posso fartelo in VB! :)
dovrebbe bastare il comando shutdown.exe di windows (magari con qualche parametro).
c'era forse qualche problema con windows NT/2000 come dice matpez, cmq cerca shutdown in google gruppi perché ci sono diverse discussioni a riguardo ;)
Originariamente inviato da recoil
dovrebbe bastare il comando shutdown.exe di windows (magari con qualche parametro).
Che io sappia shutdown.exe non è incluso in Windows... E' un programma esterno...
LPTSTR lpszSystemInfo; // pointer to system information string
DWORD cchBuff = 1024; // size of computer or user name
TCHAR tchBuffer[1024]; // buffer for string
m_bCloseApps = true;
m_bReboot = true;
lpszSystemInfo = tchBuffer;
// Get and display the name of the computer.
if(GetComputerName(lpszSystemInfo, &cchBuff)) {
CString str;
str+= _T(".:: ");
str+= lpszSystemInfo;
str+= _T(" ::.");
SetWindowText(str);
}
// opens the access token associated with a process
OpenProcessToken( GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken ) ;
// retrieves the locally unique identifier (LUID) used on a specified system
// to locally represent the specified privilege name
LookupPrivilegeValue( NULL, SE_SHUTDOWN_NAME, &(TokenPrivileges.Privileges[0].Luid));
TokenPrivileges.PrivilegeCount = 1;
TokenPrivileges.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
// enables or disables privileges in the specified access token
AdjustTokenPrivileges(hToken, FALSE, &TokenPrivileges,sizeof(TOKEN_PRIVILEGES), NULL, NULL);
if(!InitiateSystemShutdown( NULL, /*operates on localhost*/
NULL, /*doesn't display any message*/
0, /*initiates operations immediately*/
m_bCloseApps,
m_bReboot) ) {
CString str;
str.Format("Errcode: %d - see Windows Error Codes dcumentation", GetLastError());
MessageBox(str, _T("An ERROR occurred"), MB_ICONERROR);
}
Questo sopra è solo per Windows 2000/XP...
vBulletin® v3.6.4, Copyright ©2000-2025, Jelsoft Enterprises Ltd.