Jump to content

Shut Down Script


Recommended Posts

I have made a script which is placed in c:\ and removes c:\windows\prefecth\*.*. how to make it run every time i press shut down. usually i configure it by the command gpedit.msc in the run box. but i want to make it from the registry (unattended). any ideas?

Link to comment
Share on other sites


Whether it's a shutdown or logoff script, all gpedit.msc does is write an entry to the registry. It took me less than 60 seconds to discover (simply by adding a script and then using regedit to search for that name) that the key for shutdown scripts is:

HKLM\Software\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine\Scripts...

Adding a script adds multiple keys below that path. You should try adding a script using gpedit and examine the changes. It shouldn't be too hard to then create custom .reg (Or, better yet, WSH scripts using RegWrite) to add shutdown scripts.

Link to comment
Share on other sites

why not just add it to your startup? Whats it matter if theyre deleted right before you log off or right when you logon? This way all you need to do is make a batch file and toss it in there...

Link to comment
Share on other sites

it matters. if you remove your files from the prefetch folder and restart immediately you will see how faster it loads without those files. there is no effect to remove them on startup because later when you use your pc your prefecth folder will be full of files and it will load slow. try this and you'll see better startup speed of windows. i found the keys in the registry and they are as follows:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine\Scripts]

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine\Scripts\Shutdown]

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine\Scripts\Shutdown\0]
"GPO-ID"="LocalGPO"
"SOM-ID"="Local"
"FileSysPath"="C:\\WINDOWS\\System32\\GroupPolicy\\Machine"
"DisplayName"="Local Group Policy"
"GPOName"="Local Group Policy"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine\Scripts\Shutdown\0\0]
"Script"="C:\\windows\\system32\\ntbootos.bat"
"Parameters"=""
"ExecTime"=hex(b):00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine\Scripts\Startup]

[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\System\Scripts]

[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\System\Scripts\Shutdown]

[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\System\Scripts\Shutdown\0]
"GPO-ID"="LocalGPO"
"SOM-ID"="Local"
"FileSysPath"="C:\\WINDOWS\\System32\\GroupPolicy\\Machine"
"DisplayName"="Local Group Policy"
"GPOName"="Local Group Policy"

[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\System\Scripts\Shutdown\0\0]
"Script"="C:\\windows\\system32\\ntbootos.bat"
"Parameters"=""
"ExecTime"=hex(b):00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00

[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\System\Scripts\Startup]

EDIT: of course you might put ntbootos.bat into system32. my ntbootos.bat is:

del "c:\windows\prefetch\*.*" /q

Link to comment
Share on other sites

Well, speeding computer by deleting prefetch file is only hoax... Only time, when it matters is when there is too much prefetching files - I mean after half year or so.

Personally I am deleting prefetch directory every month using scheduled tasks...

Link to comment
Share on other sites

Well, speeding computer by deleting prefetch file is only hoax... Only time, when it matters is when there is too much prefetching files - I mean after half year or so.

Personally I am deleting prefetch directory every month using scheduled tasks...

i used to think the same way but my computer is p4 2,6 ghz 512 mb ram .... and when the boot screen appeared the blue thing was moving 6-10 times. i tryed everything, boosting programs, registry cleaning programs, even format didn't help. i tryed a program of microsoft which is designed to make booting faster but it didn't help too. one day I read about this in a forum and thought to myself "What will i lose if i try it?". after i tryed the blue thing moved just one time. it really worked. i don't want to lie you, just try!

Link to comment
Share on other sites

Heh, sound strange :) I am never turning off my computer at works and hibernating at notebook and tablet, so I dont solve problems like this. But prefetching shouldnt cause slow problems like this...

Well, but reasons R not important, important is you find your solution and it is working :)

Link to comment
Share on other sites

Correct me if Im wrong, but isnt the entire reason prefetching exists is to speed up loading times of applications? So if you remove these its going to slow down the overall startup time of all of your programs which use it.

I dont know about you guys, but I restart my pc maybe once every other week and Id much rather have my programs load up faster over my pc booting up an extra 3 seconds faster.

Just my 2 cents.

Link to comment
Share on other sites

  • 5 years later...

I'm trying to run a bat script to kill windows audio services at shutdown due to it hanging. My batch file is in working order as i've checked that out. My problem is the registry.

I've input all the data supplied above into the registry (ovbviously changed the file paths! lol) But to no avail.

If someone could help me with this it would be awesome.

Link to comment
Share on other sites

  • 3 months later...

Ahh prefetch

There is so much BS spread about it ...enable/disable..how often to clear etc

Heres the scoop, according to...well, me

1) Install Windows

2) install applications

3) clear prefetch - you want to do it now because it will have prefetch data for all your setup .exe's and .msi's etc, and you dont need those fetched at boot

4) reboot

5) go about your life and once every 3 months or so (or more if youre installing lots of software) clear it

6) worry about more important things.....

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...