Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.

Windows 7: Batch, Registry & UAC

05 Mar 2010   #11

Microsoft Windows 7 Ultimate (x64)

For further reference if anyone wants to build something similar, here's a dummy code. You only need to modify the red parts:


:: Are we intruders?
REG QUERY HKCU\Software\SOFTWARE TREE /v SOME SOFTWARE KEY (eg Version) > nul 2>&1
IF %ErrorLevel%==0 GOTO Error
IF %ErrorLevel%==1 GOTO Ok

:: I really dislike loops
SET del=

:: How about getting the driveletter?
set ltr=%cd:~0,3%

:: Write to temporary REG
ECHO Adding keys...
> %TEMP%.\TEMPREG.REG ECHO Windows Registry Editor Version 5.00

:: Use and copy the following line to add more trees (copy it below your keys for another tree!)

:: Use and copy the following line to add more keys (copy it below the right tree!)

:: For a key that requires a path, let's point it using the current drive letter (if your path contains spaces, enclose it with speech marks. eg \"Program Files"\\Software)
>>%TEMP%.\TEMPREG.REG ECHO "KEYNAME"="%ltr%\path\\path"

:: Merge Temporary REG with Registry

:: We're not doing this without purpose... Start program! (if your path contains spaces, enclose it with speech marks. eg \"Program Files"\Software)
echo Starting program...
start /wait %CD%\path\program.exe
GOTO Regdelete

echo There are already some registry keys for this program!
SET /P del=Do you want to overwrite all registry keys and start the application (Y/N)?
if /i {%del%}=={Y} (GOTO Regdelete)
if /i {%del%}=={Yes} (GOTO Regdelete)

:: Everybody's tired, let's delete the keys
ECHO Deleting keys...
> %TEMP%.\TEMPREG.REG ECHO Windows Registry Editor Version 5.00

:: Copy this line for every created tree


if /i {%del%}=={Y} (GOTO Ok)
if /i {%del%}=={Yes} (GOTO Ok)

:: Let's end this. Clear out the last variable.
SET ltr=
Save it as something.bat

My System SpecsSystem Spec
05 Mar 2010   #12
Bare Foot Kid
Microsoft MVP

W 7 64-bit Ultimate

Hello Propaganistas, glad you got it sorted; thanks for the info!
My System SpecsSystem Spec

 Batch, Registry & UAC

Thread Tools

Similar help and support threads
Thread Forum
Problem with batch file command to edit registry
reg add HTLM\Software\Microsoft\Windows\CurrentVersion\Policies\System /v DontDisplayLastUserName /t REG_DWORD 00000001 /f I am trying to hide all users at logon and I know this is where you change it but for some odd reason the syntax is wrong and I can not figure it out. Can someone please...
removing batch file from registry
recently I ran Mamu's add icons to system batch file for mame icons. I wasn't satified with the results so I was going to do a system restore. Then I learned system restore was turned off "which I turn off when I defrag then turn back on when completed". Now I can't figuere out how to remove it....
How to run a batch file at logoff & some batch scripting help please
Hiya, I'd just like to run a simple batch file at logoff to backup some settings. I plan to use Robocopy, which is what i use to more thorough backups. Two questions: 1. How make it run by clicking Start > Shutdown? (i realise i could make a shutdown batch file and run it instead, but i'd...
Backup and Restore
How do i capture a folder of registry keys and make then a exe batch?
I'm modifying an old game.. including patches, and modifications. I want to make my own installer using WinRar but WinRar doesn't do registry keys. I thought I'd make a self executing batch file with all my needed registry keys and point WinRar to that during install. I heard this was possible but...
General Discussion
Deleting registry keys with a batch file?
I downloaded a beta version of a program and it for some reason it has a "usage count" in the registry which denies access to the program after 10 uses. When i delete the key it works again but it's pretty annoying to keep deleting it through the registry all the time. I want to make a batch...
General Discussion
Batch editing of Registry
I want to edit my registry to remove EVERY reference to a program which I have uninstalled, but which still has dozens (or more) of references still embedded in the registry. Is there a registry editor in which I can enter one single word, and the editor will search out every mention of that...

Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 11:02.
Twitter Facebook Google+ Seven Forums iOS App Seven Forums Android App