I have created a powershell script I would like run at shutdown, and when I add it using gpedit.msc it executes exactly the way I would like.

However, I want to move it from C:\xyz.ps1 to C:\Program Files\abc\xyz.ps1, and when I do so it silently fails - what am I doing wrong?


The 'browse' button in the 'Add a Script' dialog from the "Startup Properties" or "Shutdown Properties" dialog invoked from gpedit.msc allows you to browse to paths containing spaces, but if you do so, you need to manually enclose the path in quotes after browsing.

This doesn't seem very intuitive to me so I'm posting it here in case it saves someone else the trouble of finding out the hard way.

  • Admittedly, it would be nice if the GUI did it for you, but quoting spaces in a path is a pretty universal practice. – EBGreen Aug 13 '12 at 13:01
  • 1
    of course - on the command line, or in a script, but here it is highly unexpected to have to do it manually I think - can you think of any other single place you have to do it? You don't have to do it from within the "Run" box invoked with WINDOWS+R for example. – Jack Douglas Aug 13 '12 at 13:25
  • Yes, because the GUI does the quoting. – EBGreen Aug 13 '12 at 13:28
  • You have to do it in SCCM for instance. – EBGreen Aug 13 '12 at 13:29
  • 3
    Pretty sure that GPEdit.msc would be using the Microsoft Management Console. This is an old piece of software and actually doesn't have a whole lot of functionality in and of itself. It basically just hosts plugins. So it is very reliant on the plugins doing nice things. The GPEdit.msc plugin has also been around for quite some time and should probably been updated a long time ago to provide nice bells and whistles like quoting paths with strings. – EBGreen Aug 13 '12 at 13:36

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

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