How to log the output of startup.bat from a GPO

batch-filegroup-policylogging

I'm trying to write some .bat files for GPO. I would like a way to see the output of the script to help debug problems. For the life of me I can't get it to log anything.

I have tried the following…

I created two batch files. The first had one line "call startup.bat > c:/startup.log", and the 2nd one was real startup.bat file. It didn't create the log file when I rebooted the computer the GPO was applied to. I did a "gpresult /z" which showed the policy being applied to the computer in question.

Then I delete the first batch file and change the policy to have the Parameters of " > c:\startup.log" still not working.

The startup.bat file is just some commands to generate some output.
dir
ipconfig /all

Never mind it seems to be working now. Not sure what I did to get it working. ???

Best Answer

It sounds like the user is not an administrator and/or the CMD prompt is not running with elevated privileges. Try piping your output to a safer folder like so:

call startup.bat >%temp%\startup.log