Link to home
Start Free TrialLog in
Avatar of ProjNet
ProjNetFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Batch File help - delete reg key and install software

Hello,

I'm looking for a batch script that will query to see if a reg key of 'PendingFileRenameOperations' is present in the following location: "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\"

I don't want to know the value of this key, I just need it deleting if it exists, after this I need to trigger an software installation.

So in summary, query the key, delete it then install software, if the key does not exist then I still need the software to install. what I've got so far:

reg query  /v  "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\PendingFileRenameOperations"

if %ERRORLEVEL% == 0 goto DELETE
if %ERRORLEVEL% == 1 goto Install

:DELETE reg delete "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager" /v PendingFileRenameOperations /f

:Install %~dp0Agent-Windows-x64-7-50-6422.exe /s /v" SILENTINSTALLDIR=\"C:\Software\Evault\" ACCOUNTTYPE=localsystem REGISTERWITHWEBCC=true AMPNWADDRESS=amp-proxy.itservicedesk.uk.com AMPUSERNAME="Username" AMPPASSWORD="Password" KEEPAMPREGISTRATION=true FEATURECLUSTER=ON FEATUREEXCHANGEMAPI=OFF FEATUREEXCHANGE=ON FEATUREEXCHANGE2010=ON FEATUREMAESTRO=OFF FEATUREORACLE=OFF FEATURESHAREPOINT=OFF FEATURESQL=ON FEATUREVOLUMEIMAGE=ON /qn"

User generated image
The script does not need to include the path of the installation as it's in the same directory as the script.
ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Be warned however that this PendingFileRenameOperations is used by all software installers including windows update to replace system files on startup that are in use once windows has started, and deleting this key may very well invalidate or corrupt any installed software or windows updates, rendering your computer unable to startup.
Avatar of ProjNet

ASKER

Spot on, thank you.
Avatar of ProjNet

ASKER

Yes you're right, I've informed the client of the risks and they're willing to accept it.

Thanks for the script, it worked perfectly.