Link to home
Create AccountLog in
Avatar of notta3d
notta3dFlag for United States of America

asked on

Can Gpedit information be entered by script?

I'm looking to add some information with a script that I normally would add manually with gpedit. I'm trying to set the auto-config URL in Gpedit -> User Configuration -> Windows Settings -> Internet Explorer Maintenance -. Connection -> Automatic Browser Configuration. It's complicated, but we have to run this at the users desktop. We have a script that we run on every machine that we work on and I would like to add this to our script. Can this be done with VB? I would really appreciate some help because this is one of the final things we need to do?
Avatar of Jared Luker
Jared Luker
Flag of United States of America image

You could just edit the registry directly and run the script from your login scripts.
Set WshShell = CreateObject("WScript.Shell")
 
PathToConfigFile = "\\server\share\config.ins"
 
WshShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\AutoConfigURL",PathToConfigFile,"REG_SZ"

Open in new window

oops...
Set WshShell = CreateObject("WScript.Shell")
 
PathToConfigFile = "\\server\share\config.ins"
 
WshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\AutoConfigURL",PathToConfigFile,"REG_SZ"

Open in new window

Avatar of notta3d

ASKER

Thanks for the reply. It's a very complicated situation here. We don't have rights to any of the servers and getting anything added like that takes an act of god. With that being said the use of the login scripts is not an option. Basically I want to set the auto-config URL property for any user that might use the machine. Most of our machines here are used by multiple users. Can this be done while running a script at the machine itself?
Sure... if you have a way to drop that script into the startup group on the local machine, it will run whenever someone logs into the machine.

If you don't have a way to push the script out automatically, then you might have to touch each machine.

I would recommend that you create a script that calls your own login script on the network.  That way, you only have to touch the machines once to put the calling script in the startup group.  If you want to make a change that you want to do on all machines, then you can just change the script that is on the network.
I forgot to mention that needs to be in the startup group for all users (i.e. C:\documents and Settings\all Users\Start Menu\Programs\Startup)
Avatar of notta3d

ASKER

I'm not crazy about leaving something in startup. I thought just about everything could be scripted, so I guess we're saying that this cannot be done at the time we run our script? We only run this script when we work on a machine. i.e, after setting up a new machine i.e after rebuilding a machine from a dead hard drive.
ok... no problem.  Just add the code to the script that you run manually or save it out as an independent script and run the external script from inside your main script.  Your choice.
Avatar of notta3d

ASKER

Thanks Jarad. I'm assuming you mean your script you posted above? That is set to important for the current user, but I would like to handle it for any user that might log into the machine. Is there a HKEY_LOCAL_MACHINE equivalent that will set the auto-config for any user that logs in?
Good point.  There is not a HKLM registry key for this.  It's a per user setting.  That is where I was going with the script in the startup group before you distracted me!  =)

In order for that setting to be set for every user logging into the machine you have to use a login script to modify that registry key (since you can't do a gpo or AD based script).
Avatar of notta3d

ASKER

Yea I kind thought you couldn't do it, but I'm surprised every day what you can accomplish with scripting. Here's a wild idea, can the default user.dat be edited? When a user logs on to a machine for the very first time the user.dat file is generated from the default user.dat correct? Could I log on with a new account, make the reg changes, logout, copy the user.dat from the current user into the default user.dat? That way the key would be in there for every user? What do you think?
Yes... you can do that for sure.  But use the profile copy function that is in the users profile button of system properties (don't just copy the dat file).

You'll have to do it for every computer you deploy, so it will be annoying, but you can do it.
Avatar of notta3d

ASKER

haha, ok I see your point, but are you ready for it? Can that be scripted now?  hehe, like I said every machine that we work on we run this script when we're done, so I'm trying to add this last part in so everything is pretty much automated. If I have to have the team use the profile copy function I know some the the, non-motivated techs, will not do it. That's why I'm  automating everything, as much as possible anyway :)

It was very easy when I was thinking all I had to do was overwrite c:\documents and settings\default user\NTUSER.DAT with a modified version. Can the profile copy tool be scripted?
Avatar of notta3d

ASKER

Good link, but I had a brain fart. I only have to edit the default ntuser.dat one time(on a clean build) and then put that up on a network share or include it with my script and have it copied over to replace the default user.dat on each machine. Is that how you see it?
ASKER CERTIFIED SOLUTION
Avatar of Jared Luker
Jared Luker
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer