0

With group policies I have setup a .bat script that runs when windows is shutdown. The script runs an .exe that does a backup of my data. Under Win 7 the execution of the .exe appeared on the screen when windows was shutdown or restarted. This allowed to terminate the backup (.exe provides this option) if it was not required, e.g. in case of a restart.

In my newly setup Windows 10, the script runs (I can tell this from the time the shutdown takes) but the execution of the script is not visible on the screen and can therefore not be terminated if not needed.

Questions:

  • Is there any way to make the execution of the .exe in the shutdown script visible on Win 10?
  • Is it possible to determine inside a .bat script if windows is shutdown or restarted?

Thanks for your help.

Hannes Schmid
  • 379
  • 3
  • 14
  • 1
    Under what user account do you expect the batch file to run? I wouldn't expect that to be the same user account as the interactive user. As a result, it's logical the window is invisible. More precisely, visible windows belong to the interactive logon session and shutdown scripts do not. – MSalters Aug 25 '16 at 10:34
  • IIRC there are task scheduler triggers for run on startup/shutdown, try that with the run as current user option set. – Alex K. Aug 25 '16 at 10:46
  • @MSalters: The script as well as the .exe run under adiministrator. Your explenation sounds resonable thought do not explain the difference between Win 7 and Win 10. – Hannes Schmid Aug 25 '16 at 19:27
  • @To Alex K: Thanks for the hint. I was not aware of this functionality; I will definitly give it a try. – Hannes Schmid Aug 25 '16 at 19:29
  • @HannesSchmid: Microsoft has been tightening security incrementally. – MSalters Aug 26 '16 at 07:03
  • @To Alex K: Your sugestion is not working for me, since the windows shutdown does not wait for the execution of the shutdown task to complete (if I made no mistake). Backup just takes to long. – Hannes Schmid Aug 27 '16 at 13:13

1 Answers1

1

There is a setting in gpedit that defines if the statements exeucuted in a shutdown script should be shown.

  • gpedit.msc: computer configuration -> adminstrative templates -> system -> scripts: You find 'Show statements when executing shudown scripts' (or similar since translated from German!). Only if activated will you see what the computer does during shutdown. 'Not activated' is the Default.

I found the solution via the following question asked here in Stack Overflow

Hannes Schmid
  • 379
  • 3
  • 14