|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Senior Member
Iscritto dal: Jul 2002
Città: Bergamo
Messaggi: 2084
|
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.
__________________
CPU AMD PHENOM II X6 1055T @4000*DailyUse*Max.4311MHz: raffreddato a liquido con Corsair H70, MoBo GigaByte 870A-UD3, 4 Gb (2Gb x 2) Kingston 1600 MHz, AMD RADEON Sapphire Hd 6870@TOXIC, 1 SSD samsung 128 Gb, 1 hd Samsung 180 Gb, 1 hd Samsung 80 Gb,1 hd Western Digital 500 Gb, S.O. Win7 64 bit, ADSL 7000 kbps, Ali Enermax MODU82+ 525W, il tutto in un bel case Cooler Master 690 II LITE - Window Edition. Aiuta la ricerca scientifica con il tuo PC!! |
|
|
|
|
|
#2 |
|
Senior Member
Iscritto dal: Aug 2002
Città: Biella
Messaggi: 1882
|
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!
__________________
"Analizzando e valutando ogni giorno tutte le idee, ho capito che spesso tutti sono convinti che una cosa sia impossibile, finchè arriva uno sprovveduto che non lo sa e la realizza!" A. Einstein |
|
|
|
|
|
#3 |
|
Senior Member
Iscritto dal: Jul 2002
Città: Milano
Messaggi: 19149
|
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 |
|
|
|
|
|
#4 | |
|
Senior Member
Iscritto dal: Apr 2000
Città: Vicino a Montecatini(Pistoia) Moto:Kawasaki Ninja ZX-9R Scudetti: 29
Messaggi: 53971
|
Quote:
|
|
|
|
|
|
|
#5 |
|
Member
Iscritto dal: Feb 2002
Città: Banana Republic
Messaggi: 226
|
this should do the trick (MFC code)
Codice:
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);
}
|
|
|
|
|
|
#6 |
|
Senior Member
Iscritto dal: Apr 2000
Città: Vicino a Montecatini(Pistoia) Moto:Kawasaki Ninja ZX-9R Scudetti: 29
Messaggi: 53971
|
Questo sopra è solo per Windows 2000/XP...
|
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 18:57.


















