Solved

VBS or BAT to update the local registry on domain pc run by poweruser

Posted on 2008-10-15
7
1,044 Views
Last Modified: 2012-05-05
VBS or BAT to update the local registry on domain pc run by poweruser.

I am trying to create a bat or vbs script to that a designated poweruser can run on a Domain Users machine to edit the registry.  The Domain Users account have been locked down with Group Policy so I am using the 'runas' command so johndoe (the poweruser, who as admin priv on every machine) can execute the script and update the registry key.  I have two files, the first is a batch file as shown below with one line and the second is the .reg file to alter the registry.  The script HAS TO BE RUN while the current domain user is logged on the change the key.  I keep getting directory doesn't exist errors.  Could someone please help me?


FixIE.bat:
runas /profile /env /user:thedomain\johndoe "regedit \"\\DC01\Shared Folder\Scripts\FixIE\FixIE.reg\""


FixIE.reg:
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\TypeLib\{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}\1.1\0\win32]
@="C:\\WINDOWS\\system32\\ieframe.dll"
0
Comment
Question by:ascnd
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 67

Expert Comment

by:sirbounty
ID: 22727498
How about running it from a 'command station' under the admin or power user account?

1) Create a list of devices you want to update - c:\Computers.txt
2) Create the following batch file:


@echo off
for /f %%a in (C:\Computers.txt) do call :process %%a
goto :eof
 
:process
set pc=%1
reg add \\%pc%\hkey_classes_root\typelib\{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}\1.1\0\win32 /ve /d "C:\\WINDOWS\\system32\\ieframe.dll"

Open in new window

0
 
LVL 67

Expert Comment

by:sirbounty
ID: 22727501
Or if you want to use runas, try it with reg.exe instead:

runas /profile /env /user:thedomain\johndoe reg add \\%pc%\hkey_classes_root\typelib\{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}\1.1\0\win32 /ve /d "C:\\WINDOWS\\system32\\ieframe.dll"

0
 

Author Comment

by:ascnd
ID: 22727626
The proposed solution below (which is the one I want to use) has %pc% in it.  There are many PC's can't this be eliminated.  If so what would the line look like?

runas /profile /env /user:thedomain\johndoe reg add \\%pc%\hkey_classes_root\typelib\{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}\1.1\0\win32 /ve /d "C:\\WINDOWS\\system32\\ieframe.dll"
0
Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

 
LVL 67

Accepted Solution

by:
sirbounty earned 500 total points
ID: 22727650
If running it from a local computer, change %pc% to %computername% or simply remove that section altogether:

runas /profile /env /user:thedomain\johndoe reg add \\%computername%\hkey_classes_root\typelib\{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}\1.1\0\win32 /ve /d "C:\\WINDOWS\\system32\\ieframe.dll"

runas /profile /env /user:thedomain\johndoe reg add hkey_classes_root\typelib\{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}\1.1\0\win32 /ve /d "C:\\WINDOWS\\system32\\ieframe.dll"
0
 
LVL 21

Expert Comment

by:AmazingTech
ID: 22727835
Hmm. I don't think you can add or query hkey_classes_root remotely.

You need to do it through HKLM. You probably want to add the /f too.

Of course on the local machine use sirbounty's last runas command above. Add /f to not prompt you.
@echo off
for /f %%a in (C:\Computers.txt) do call :process %%a
goto :eof
 
:process
set pc=%1
reg add \\%pc%\hklm\software\classes\typelib\{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}\1.1\0\win32 /ve /f /d "C:\\WINDOWS\\system32\\ieframe.dll"

Open in new window

0
 

Author Comment

by:ascnd
ID: 22727875
Sirbounty,

Thank you for the solution.  I only had to alter one thing.  I had to add quotes around the command and then I had to add a \ to the nested quotes to get it to work fully.

runas /profile /env /user:c21nebraska\ghasse "reg add hkey_classes_root\typelib\{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}\1.1\0\win32 /ve /d \"C:\\WINDOWS\\system32\\ieframe.dll\""
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 22729994
Glad I could help - thanx for the grade! :^)
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
This article was inspired by a question here at Experts Exchange (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28629170.html). The requirements stated in that question are (1) reduce the file size of a large number of…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question