Sysinternals Homepage
Forum Home Forum Home > Sysinternals Utilities > PsTools
  New Posts New Posts RSS Feed - Using PSExec to edit the registry
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Using PSExec to edit the registry

 Post Reply Post Reply
Author
Message
1935 View Drop Down
Newbie
Newbie


Joined: 08 November 2012
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote 1935 Quote  Post ReplyReply Direct Link To This Post Topic: Using PSExec to edit the registry
    Posted: 08 November 2012 at 10:40pm
I am trying to remove a registry entry on several remote computers using psexec and regedit.

I am running the following batch file:

psexec \\%machine% regedit /s "\\poly-tech\d$\Support_tech\Support_Programs\Scripts & Programming\Registry Adds-Deletes-Mods\Remove Java Auto update entry\RemoveJavaAutoUpdate.reg"

The contents of RemoveJavaAutoUpdate.reg is:

Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]
"SunJavaUpdateSched"=-

When I run the batch file it enacts psexec and exits with error code 0 which usually means successful.  But it does not remove the registry entry.  What am I doing wrong.  thanks already
Back to Top
1935 View Drop Down
Newbie
Newbie


Joined: 08 November 2012
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote 1935 Quote  Post ReplyReply Direct Link To This Post Posted: 13 November 2012 at 5:01pm
It stinks that this post has been on here nearly a week and not 1 reply!!  I figured out a way to make it work.  For some reason it will NOT work if you reference the .reg file on a remote computer.  However, if you copy the .reg file to the local computer (like c:\temp) it will run just fine.  Just remember if you are running this command on a 64-bit system the registry path will be different.  Below are the scripts I used:  Good luck getting help on this site.

<< Batch file >>
@echo off
REM This file assumes you have psexec installed
REM Ask for machine name or IP
set /p machine= Please enter the machine name or ip:
REM check for workstation online, if not exit
ping %machine% | find "Reply"
if errorlevel 1 goto :offline
if errorlevel 0 goto :removal

:offline
echo Workstation not online
pause
exit

:removal
copy "S:\Support_Programs\Scripts & Programming\Registry Adds-Deletes-Mods\Remove Java Auto update entry\RemoveJavaAutoUpdate.reg" \\%machine%\c$\temp
psexec \\%machine% regedit /s "c:\temp\RemoveJavaAutoUpdate.reg"
pause

<< Reg file  RemoveJavaAutoUpdate.reg>>
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]

"SunJavaUpdateSched"=-



Edited by 1935 - 13 November 2012 at 5:03pm
Back to Top
WindowsStar View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 June 2010
Status: Offline
Points: 625
Post Options Post Options   Thanks (0) Thanks(0)   Quote WindowsStar Quote  Post ReplyReply Direct Link To This Post Posted: 14 November 2012 at 7:33am
How about just using REG built into Windows 7:
 
REG DELETE KeyName [/v ValueName | /ve | /va] [/f]
  KeyName    [\\Machine\]FullKey
    Machine  Name of remote machine - omitting defaults to the current machine.
             Only HKLM and HKU are available on remote machines.
    FullKey  ROOTKEY\SubKey
    ROOTKEY  [ HKLM | HKCU | HKCR | HKU | HKCC ]
    SubKey   The full name of a registry key under the selected ROOTKEY.
  ValueName  The value name, under the selected Key, to delete.
             When omitted, all subkeys and values under the Key are deleted.
  /ve        delete the value of empty value name (Default).
  /va        delete all values under this key.
  /f         Forces the deletion without prompt.
Examples:
  REG DELETE HKLM\Software\MyCo\MyApp\Timeout
    Deletes the registry key Timeout and its all subkeys and values
  REG DELETE \\ZODIAC\HKLM\Software\MyCo /v MTU
    Deletes the registry value MTU under MyCo on ZODIAC
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down