[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

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

Posted on 2004-10-27
5
Medium Priority
?
2,634 Views
Last Modified: 2013-11-18
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
Comment
Question by:perove
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 3

Accepted Solution

by:
StGoY earned 1000 total points
ID: 12422527
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
 
LVL 96

Expert Comment

by:Lee W, MVP
ID: 12422589
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
 
LVL 9

Author Comment

by:perove
ID: 12422732
thanks steph..

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

perove¨
0
 
LVL 6

Expert Comment

by:kapes
ID: 12422745
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
 
LVL 9

Author Comment

by:perove
ID: 12422765
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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes a user will call me frantically, explaining that something has gone wrong and they have tried everything (read - they have messed it up more and now need someone to clean up) and it still does no good, can I help them?!  Usually the standa…
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question