[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How to run a batch file at shutdown on XP HOME?

Posted on 2004-11-18
24
Medium Priority
?
469 Views
Last Modified: 2008-01-09
I would like to run a script/batch file when I choose Start>Shutdown.

I have looked at programs like Karen's Show Stopper, but they only run a script/batch before THEY shutdown the computer.

I have heard about programs like LastChance, but I would like a method that does not have yet another process running to achieve it.

I've looked at Group Policy, but it is not a part of XP Home. I tried to enter the registry entries for GP manually, but nothing happened on shutdown. The GP core is probably not even in XP Home.

Scheduled Tasks only has an option for logon / startup.

Is there any other method [other than upgrading to XP Pro :) ] ?
0
Comment
Question by:KeefeJohnson
  • 11
  • 9
  • 3
23 Comments
 
LVL 11

Expert Comment

by:jgiordano
ID: 12616330
I am not that familiar with xp home but if you can issue a command from the command line check if you could do a shutdown.exe /? (open up a command window so the screen stays up and you can see if the file is in your system32 folder)

If so you could create a batch file to first execute whatever it is you need to do upon shutdown then issue the shutdown .exe command within the same batch file. keep this shortcut on your desktop so you can just dbl click it to shut the computer!
0
 
LVL 2

Author Comment

by:KeefeJohnson
ID: 12616551
Yes, but I would like it to be automatic through Start>Stutdown
0
 
LVL 11

Expert Comment

by:jgiordano
ID: 12616588
Start>Shudown is just a link to the shutdown command.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 2

Author Comment

by:KeefeJohnson
ID: 12616624
The reason for the shutdown batch file...
I have changed my WinXP kernel to display a different boot screen at startup. If Windows Update installs a kernel patch, it will ask if I want to restart now or later. If I click restart now, I want windows to tell me if the kernel has changed so that I don't use my modified boot screen. I can't configure Windows Update to run a batch before shutting down. So I want windows to do it automatically like Group Policy does in WinXP Pro.
0
 
LVL 11

Expert Comment

by:jgiordano
ID: 12616830
Add this key and see if it works - what I did was add the shutdown script through gpedit.msc then looked for the key in the reg

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

Following keys

(String value) Parameters - (value) whatever params
(String Value) Parameters - (value) The script location
(Binary) ExecTime - 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0
 
LVL 11

Expert Comment

by:jgiordano
ID: 12616850
Do the same keys here

HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\System\Scripts\Shutdown\0\0
0
 
LVL 11

Expert Comment

by:jgiordano
ID: 12616915
Please backup the registry and do a system restore point first
0
 
LVL 2

Author Comment

by:KeefeJohnson
ID: 12616990
I've tried that already. It seems that not only is gpedit.msc unavailable, but the core isn't even there in XP Home. Windows doesn't do anything even when I do it manually like that in the registry. (Win2000 had GP, why couldn't MS have continued it in XP Home?)
0
 
LVL 11

Expert Comment

by:jgiordano
ID: 12617005
even if you add the second key alone?
0
 
LVL 2

Author Comment

by:KeefeJohnson
ID: 12617011
I have an idea... I'll change Shutdown to Startup, and use RegMon from SysInternals.com to monitor registry acces during boot. Then I'll find out if windows is even looking for the key...
0
 
LVL 11

Expert Comment

by:jgiordano
ID: 12617039
there is one more this with the registry do a search for shutdown and there should be an event to play the shutdown wave file I found it when I did the search. Maybe you could put the script where is calls that file
0
 
LVL 2

Author Comment

by:KeefeJohnson
ID: 12617045
Interesting idea ... Never thought of that ... I'll try it...
0
 
LVL 2

Author Comment

by:KeefeJohnson
ID: 12617138
No, I think Windows is designed to not let that get through. I clicked the preview sound button, and it said the sound file (my batch file) was either damaged or was not a vaild sound file. I tried it with "Critical Stop" and made an error come up. File Monitor said that Windows accessed the file, but never ran it. "Invalid sound file..." "Invalid sound file..." MS, why shouldn't it work? :)
0
 
LVL 11

Expert Comment

by:jgiordano
ID: 12617185
One more thing I thought of; if you remove the shutdown.exe from the system directory where it is sourced. see if you get an error that it can't find the file when you try to use the start>shutdown. If so then maybe you could put a modified shutdown.exe that points to your script first then the actual shutdown.
0
 
LVL 7

Expert Comment

by:tymes
ID: 12617678
Modify your boot.ini file and not your kernel.
/BOOTLOGO
Use this switch to have Windows XP or Windows Server 2003 display an installable splash screen instead of the standard splash screen. First, create a 16-color (any 16 colors) 640x480 bitmap and save it in the Windows directory with the name Boot.bmp. Then add "/bootlogo /noguiboot" to the boot.ini selection.
0
 
LVL 2

Author Comment

by:KeefeJohnson
ID: 12617770
tymes... Good idea too. I've thought of it, but I wanted a boot screen that had a moving progress bar like the standard, which /bootlogo won't do. I'll do it though if I can't find any other ideas. Thanks.

Report from Registry Monitor: XP Home never accesses a "Group Policy" or "Policies\Microsoft\Windows\System" key when booting up. So I think the GP core isn't even in the OS.

Now I'll try jgiordano's shutdown.exe idea... Maybe I can just replace it with my own...
0
 
LVL 2

Author Comment

by:KeefeJohnson
ID: 12617862
Windows System File Protector :(   I can't delete the file or it comes right back. If I had XP Pro, I could disable access to the file. Is there a way to turn off SFP?
0
 
LVL 2

Author Comment

by:KeefeJohnson
ID: 12638921
Nevermind SFP (WFP). I'll just have to make a progam to monitor when Windows is shutting down.
0
 
LVL 7

Accepted Solution

by:
tymes earned 200 total points
ID: 12639335
If you're worried about windows updating the kernel and you want to check it hasn't in your own shutdown script.  Will that work?  It requires you to reboot because it is going to update the .dll in a _startup_ script (the file is in use so that is why it has to restart).  Windows will flag the file to be changed next boot up, you'll run your script when you shutdown won't it find nothing? It will start up and change the file when starting in a wininit.ini or similar, not before it shutsdown.

So perhaps you need to use a startup script or eventually use a much smarter shutdown script that checks that an update is scheduled and schedules one of it's own.

Find an update that already updates the file in question and find out how and when it works.  You'll need to know the exact mechanism to counteract the change.  Is the change you want to do a modified .dll or is it a patch that modifies an existing dll?

0
 
LVL 7

Expert Comment

by:tymes
ID: 12639384
You might also try seeing if gptext.dll exists anywhere on a XP Home machine, if it doesn't then get it from an XP Pro (or from some update like the full Service Pack 2) and copy it to c:\windows\system32, next...
C:\WINDOWS\system32>REGSVR32 gptext.dll
And see if shutdown scripts start working...

0
 
LVL 11

Assisted Solution

by:jgiordano
jgiordano earned 200 total points
ID: 12643928
If you ever figure this out please post this was a pain!
0
 
LVL 2

Author Comment

by:KeefeJohnson
ID: 12646225
You're right tymes. Although you didn't give me a way to check the kernel at shutdown, you pointed out that there is no point in doing so! I'll probably use your boot.ini solution.

I'll check on that gptext.dll. It would be nice to have GP on XP Home even if I don't use it for this purpose. I'll post the results today.

**** I'm splitting the points between you for your help with this question. Thanks. ****
0
 
LVL 2

Author Comment

by:KeefeJohnson
ID: 12648260
gptext.dll didn't work for me. Thanks anyway!
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We have adopted the strategy to use Computers in Student Labs as the bulletin boards. The same target can be achieved by using a Login Notice feature in Group policy but it’s not as attractive as graphical wallpapers with message which grabs the att…
If you have done a reformat of your hard drive and proceeded to do a successful Windows XP installation, you may notice that a choice between two operating systems when you start up the machine. Here is how to get rid of this: Click Start Clic…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses
Course of the Month19 days, 13 hours left to enroll

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question