• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2645
  • Last Modified:

CMD (Bat) file -read reg value -> and take action

Hi
I'm looking for a way in a script fil to read a registry value and depend on the value there run a exe file.

Somthing like

IF //H_KEY_CURRENT_USER/SOFTWARE/MYAPP/VERSJON =3.0.1
Start "c:\program files\maypp1.exe"
ELSE
Start "c:\program files\maypp2.exe"


The value is type=text (if that matter)

perove

0
perove
Asked:
perove
1 Solution
 
StGoYCommented:
I had the same thing to do a while ago, read into the registry.  In order to do that, I Used a VB Script instead of a bacth file.

Simply create a text file, copy this code in, modify it to fit your needs and save it to "MyScript.vbs" (Whatever the name, as long as it's a .vbs file ;) )

=====================

Dim RegValue
Dim WshShell
Set net = CreateObject("WScript.Network")
Set WshShell = WScript.Createobject("WScript.shell")

RegValue = WshShell.RegRead("HKCU/SOFTWARE/MYAPP/VERSJON")

IF RegValue = "3.0.1" Then
   WshShell.Run "C:\Program Files\MyApp1.exe"
Else
   WshShell.Run "C:\Program Files\MyApp2.exe"
End IF

Set WshShell = Nothing

=====================

That should do the trick!!

Steph
0
 
Lee W, MVPTechnology and Business Process AdvisorCommented:
Assuming you are using 2000 or XP you can use the "REG.EXE" command to read the registry.  Then parse it with FOR and/or FIND.  (if 2000, the REG.EXE command is in the support tools on the CD.  Otherwise XP includes it).  Type REG /?  for more info on using the command
0
 
peroveAuthor Commented:
thanks steph..

(/neede to change the /slash to backslash \ )

perove¨
0
 
kapesCommented:
If you can use VBscript then above script is ideal...
and if u have to use command-line based tool then

The following links shows how you can use REG.EXE from NT resource kit within batch file and take a action according to the result...


http://www.robvanderwoude.com/ntregistry.html
0
 
peroveAuthor Commented:
kapes & leew ..Great
 thanks  
think vbscrip will do the trick for me but I will indeed have that in mind..
thanks again


perove
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now