Solved

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

Posted on 2004-10-27
2,548 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
Question by:perove
    5 Comments
     
    LVL 3

    Accepted Solution

    by:
    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 95

    Expert Comment

    by:Lee W, MVP
    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
    thanks steph..

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

    perove¨
    0
     
    LVL 6

    Expert Comment

    by:kapes
    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
    kapes & leew ..Great
     thanks  
    think vbscrip will do the trick for me but I will indeed have that in mind..
    thanks again


    perove
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    In a recent article here at Experts Exchange (http://www.experts-exchange.com/articles/18880/PaperPort-14-in-Windows-10-A-First-Look.html), I discussed my nine-month sandbox testing of the Windows 10 Technical Preview, specifically with respect to r…
    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.
    The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
    HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

    846 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

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now