naveengowdar

Distinguished
Jul 12, 2010
5
0
18,510
when ever user hits the shut down button in start menu i m trying to launch my own application, and my applications will take care of shutting down the windows, so the problem is i am not able to get a location where i can avoid launching of shut down dialog box and assign my application to shut down button in start menu. Does any one have ideas to do this? thanks in advance.
 


Since you only ask for Ideas... I'll toss this one out there..

Leave the shutdown dialog alone, but send it to your program:

When the user clicks to shut down Windows, that action calls the shutdown.exe and passes parameters according to what was requested, a shutdown or restart. Rename the shutdown.exe as you like, make your program name shutdown.exe and have your program do what it will do, and have it finally call the real shutdown program (whatever you renamed it to be), and pass params according to function desired.

This is what gets passed to Shutdown.exe...
If shutdown was clicked, it is C:\%windir%\system32\shutdown.exe -s -t 0
If restart was clicked, it is C:\%windir%\system32\shutdown.exe -r -t 0

Hope this helps.




 

naveengowdar

Distinguished
Jul 12, 2010
5
0
18,510
thanks Tigsounds, but in my case the shut down dialog box should be strictly avoided, and shutdown.exe will be invoked only after selecting shutdown( or restart ...) in shut down dialog box , so is there any way to link my application exe to shutdown button in start menu
 

naveengowdar

Distinguished
Jul 12, 2010
5
0
18,510



Can the shutdown.exe be replaced, coz i tried that soon after i replace my application named shutdown.exe the system will again replace it with its own shutdown.exe
 


Shutdown.exe is a protected system file. It can be replaced, but if it is replaced in Windows\system32 folder, it also must be replaced in the dllcache folder as well. It will then be safe.... Until you run SFC or do a windows repair. The problem is, you can't see the dll cache folder.... yet.

Copy & paste this into notepad:

Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced]
"Hidden" = "2"
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced]
"ShowSuperHidden" = "0"
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer]
"NoDriveTypeAutoRun" = "145"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\explorer\Advanced\Folder\Hidden\SHOWALL]
"CheckedValue" = "0"



Save as:

File Name:      PeekaBoo.reg     (Ok, whatever you like, just have the extension be .reg)
Save as type:  All Files

Click save

Double-click and merge into registry. I forget if restart is needed.. (It's late)
Now Windows Explorer will show everything there is in your computer. :sol:
The dll cache is in the system32 folder and it's going to be blue, so what eh?
Copy the original Shutdown.exe to a safe place, you might want to put it back someday.

Dang.. I had to edit this thing already. There's something weird about moving files out of the dll cache.
I seem to remember a cut & paste didn't work, but a drag and drop within the same drive (any folder) works. You'll see.
 
I just re-read the post, looks like he's trying to replace the actual Shut Down option in Windows to map to his own program. The issue here, if you repalce the shutdown executable with a custom program, what is his program going to call to shut down the machine?