Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

So I'm attempting to programmatically add a logon/logoff/etc script to be ran with a GPO. I add the scripts in their respective /Sysvol/blah... directory. I update the scripts.ini file correctly to reflect the new script. I update the gpt.ini file to reflect the new version (using the correct decimal to represent the right hex byte). I update the LDAP value as well.

I go into the Group Policy Management and can see the GPO. I can see the version numbers match for AD and Sysvol, however when I go to the 'Settings' tab and can see that my script isn't listed.

I then edit the GPO via the UI (opening gpedit.msc). I can see my logon script in the UI just fine. I simply click 'OK' to confirm the gpedit UI, refresh that 'Settings' tab in the Group Policy Management UI and viola it shows my script.

So it's left me wondering what is that UI doing that I'm not? Oh, and I've tried 'gpupdate /force' and that was a no go as well :( Any ideas?

share|improve this question
What are you doing with scripts that can't be done with GP prefs? – Jim B Dec 14 '11 at 21:16
Nothing special. I'm just programmatically attempting to add scripts as it's part of my application ability to automate it. – ymerej Dec 14 '11 at 21:33
I have to ask why you wouldn't just use the GPMC to begin with? In addition, gpupdate doesn't update the GPMC, it refreshes Group Policy on the client computer for the computer/user (unless specified for just the computer or just the user). In addition addendum, startup and logon scripts are not processed when gpupdate is invoked unless gpupdate is invoked with the /logoff switch. – joeqwerty Dec 14 '11 at 21:37
I am using GPMC to create the GPO, however GPMC does not allow you to add scripts (for a reason I do not know). So I was left with trying to add the scripts manually. – ymerej Dec 14 '11 at 21:41
I suspect you can't add scripts because running scripts in a GPO usually causes performance issues and is almost always completely unnecessary. – Jim B Dec 16 '11 at 0:53
up vote 2 down vote accepted

Using the documented scripting interfaces or their PowerShell counterparts for GP manipulation instead of poking around and failing should save you a lot of effort.

Specifically look at the scripting samples for exporting and importing a GPO - they work with an XML format for GPO definition which is easily generated programpatically.

share|improve this answer
This seems to be the closest thing on what I'm looking for. I know those wsf scripts use the GPMC library just like I'm using in my C# app. I ran the backup and restore and it was able to properly bring back the scripts. I guess I just need to read up more on what it's doing internally so I can replicate what the scripts are doing. Thanks! – ymerej Dec 15 '11 at 18:49

Your Answer


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.