Populate GPO from Text File using VBScript or other -
ok, need create gpo allows our users use specific programs.
gpo location:
- user configuration
- policies
- administrative templates [...]
- system
- run specified windows applications
- system
- administrative templates [...]
- policies
then setting gpo enabled , clicking on list of allowed applications --> show...
i have created excel spreadsheet containing names of programs , associated executable files other pertinent information can organize, add, delete, etc. executable files need allow our users access to.
this spreadsheet dumps executable files text file.
here example of text file looks like:
acrobat.exe chrome.exe calc.exe . . .
there lot of entries , these subject change. trying create script take text file , populate gpo automatically. don't care if have open window , run it, not need run task scheduler (although amazing if has code ready). need populate ridiculous amount of executable filenames fields.
here code found (vbscript) when run, should populate fields automatically, cannot run in group policy management editor (it runs in windows explorer window instead , ends searching of files)
' open text file, located in same path script set objfso = createobject("scripting.filesystemobject") strpath = mid(wscript.scriptfullname, 1, instrrev(wscript.scriptfullname, wscript.scriptname) -1) set objfile = objfso.opentextfile(strpath & "applist.txt") ' activate "show contents" window "list of allowed applications". ' note window must opened , should have selected in ' list want enter data before running script set wshshell = wscript.createobject("wscript.shell") wscript.sleep 1000 wshshell.appactivate "show contents" ' read file line line while objfile.atendofstream <> true ' each line contains 1 exe name exename = objfile.readline ' escape forbidden chars { } [ ] ( ) + ^ % ~ exename = replace(exename, "[", "{[}") exename = replace(exename, "]", "{]}") exename = replace(exename, "(", "{(}") exename = replace(exename, ")", "{)}") exename = replace(exename, "+", "{+}") exename = replace(exename, "^", "{^}") exename = replace(exename, "%", "{%}") exename = replace(exename, "~", "{~}") ' send exe name window wscript.sleep 100 wshshell.sendkeys exename ' move next 1 wshshell.sendkeys "{tab}" loop objfile.close
"c:\windows\system32\grouppolicy\user\registry.pol"
is policies stored. it's semi text file. try writing file.
Comments
Post a Comment