Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Anybody know of a quick way of copying a log file used by a Windows XP service either before the service starts (during boot) or after the service has stopped (during shutdown)?

Preferably using the command prompt, but would consider any free tool to do this also.

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

You can add startup and shutdown scripts in windows. I think this is the easiest way to do what you want to do. Simply create a script which copies the service log to a location of your choosing. Simply execute the command from your boot or shutdown script.

This Page has some very illustrative instructions on how to enable the startup/shutdown script capability.

share|improve this answer
    
+1 For posting the answer originally –  Diago Aug 12 '09 at 15:16
    
What happened to autoexec.bat?? –  Umber Ferrule Aug 12 '09 at 19:44
    
Autoexec.bat still exists in windows, but it runs after the services are started up. I realized that would not do you any good. –  Axxmasterr Aug 12 '09 at 20:21
add comment

A quick Google later and I've just come across Scripts (Startup/Shutdown) in the Group Policy editor (gpedit.msc). Under the headings: Local Computer Policy -> Computer Configuration -> Windows Settings -> Scripts (Startup/Shutdown). I opened Startup Properties and added a batch file to copy the desired file:

xcopy /v /c c:\service.log c:\

I've just rebooted and it did what I needed.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.