Skip to content
View in the app

A better way to browse. Learn more.

MSFN

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Shutdown scripts dont run problem

Featured Replies

Hi All,

I have a strange problem with Group Policy shutdown scripts-

I have a c# program that calls an INITIATESYSTEMSHUTDOWN command on a bunch of remote Windows XP PCs to shut them down in the evening. This works fine, but ..... the group policy shutdown scripts do not run if the PCs are shut down in this fashion!

If you walk up to one of these PCs and press the power button on the front of the system, then the PC shuts down but DOES process the shutdown scripts. Likewise, if the PC is logged on at the time the INITIATESYSTEMSHUTDOWN command is sent, then the scripts DO run before the PC shuts down!

I thought the problem may be with the INITIATESYSTEMSHUTDOWN call, but if I remotely shut down the PCs using SHUTDOWN.EXE from the NT resource kit, I get the same result, the scripts do not run!!

This is very perplexing. Does anyone have any ideas? The local eventlogs on the PCs dont log any errors about this.

Yea they definately won't run the logoff scripts. Your function is calling the "force shutdown" action that you normally can see being run by NTAUTHORITY/SYSTEM. You will be better off using comspec for "shutdown -r -t 30" where -r is restart, and -t is time, and 30 is 30 seconds, but you can use any sort of time delay you wish. This option should run your logoff scripts. If that still isn't working, try "shutdown -i -r -t 30"

Edited by Tripredacus

Are you utilizing the bForceAppsClosed == True in your call? Also, just an FYI, but using the ExitWindowsEx function provides the logoff+shutdown/reboot functionality, and should be used instead of InitiateSystemShutdown function unless you want to do this remotely (ExitWindows is a local API only).

  • Author

All,

I have tried the shutdown with both the bForceAppsClosed set to true and false but it makes no difference. Also, the idea is to power off the PCs remotely so a reboot and an ExitWindows call are out of the question.

Thanks for your help.

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.