# registry checking using a .BAT file



## softengg

Hi,

I want to check a value in the registry using a batch file...(It is actually checking whether a software is installed or not).

If that value exists, i want to quit the batch file. If that value not found, it will execute another .exe from a folder. How this is possible using a batch file........please help me.......


Thanks in advance....


----------



## devil_himself

Hello , Welcome To TSG

Try This



Code:


@echo off
setlocal
set regpath=HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer
set regvalue=NoDriveTypeAutoRun
set regdata=91
reg query "%regpath%" /v "%regvalue%" | find /i "%regdata%"
if errorlevel 1 (
    echo Data Not Found!
    call C:\YourExe.exe
    EXIT /B /0
)


----------



## softengg

Hi,
Thanks for the reply. But it shows error that too many parameters....
My batch file code is shown below:

@ECHO OFF
set regpath="HKEY_LOCAL_MACHINE\Software\Microsoft\NET Framework Setup\NDP\v3.0\Setup\Windows Presentation Foundation"
set regvalue=InstallSuccess
set regdata=1
reg query "%regpath%" /v "%regvalue%" | find /i "%regdata%"
if errorlevel 1 (
echo Please wait while .Net Framework is installing......
Start /WAIT .\MSFrameWork\dotnetfx3.exe
EXIT /B /0
)

So each time this batch file executes, it will enter into the if loop bcoz erro occurs for too much parameters.........

Please help me........


----------



## devil_himself

Hello softengg

Try This



Code:


@ECHO OFF
set regpath=HKLM\Software\Microsoft\NET Framework Setup\NDP\v3.0\Setup\Windows Presentation Foundation
set regvalue=InstallSuccess
set regdata=1
reg query "%regpath%" /v "%regvalue%" | find /i "%regdata%"
if errorlevel 1 (
      echo Please wait while .Net Framework is installing......
      Start /WAIT .\MSFrameWork\dotnetfx3.exe
      EXIT /B /0
)


----------



## softengg

Hi,

Thanks for the help.....It worked fine.....
I need to know 1 more thing.........

While batch file is running, cmd.exe window is shown.......
How can we suppress or hide this cmd.exe window????

I tried the below code in the previously posted code.......

...................
if errorlevel 1 (
echo Please wait while .Net Framework is installing......
Start /WAIT /MIN .\MSFrameWork\dotnetfx3.exe
EXIT /B /0
)

But when i used this code, it minimises the .Net Framework installation window !!!
But how can i hide the cmd.exe window ????

Please help me...........


----------



## devil_himself

Have a Look
http://forums.techguy.org/software-development/684627-hiding-dos-box-bat-execute.html


----------

