Please Read: Significant Update Planned, Migrating Forum Software This Month

See more
See less

Batch file help

  • Filter
  • Time
  • Show
Clear All
new posts

  • Batch file help


    I am trying to write a batch file which checks for a registry key(a.k.a folder) existanance in uninstall key and perl forms the below. Can some one help me with equivalent code?

    if exists(HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windo ws\CurrentVersion\Uninstall\%ProductName%) then do nothing


    sleep for 10 mins and check the regkey again. If fails sleep again and check after 10 mns. Like this for 5 times

    end if

  • #2
    Re: Batch file help

    you can try this,

    @echo off & color 6A
    title Search for registry subkey
    echo Do not close this box! &echo\
    > "%temp%.\wait.vbs" echo/wsh.sleep wsh.arguments(0)*1E3
    set wait=wscript.exe "%temp%.\wait.vbs"
    Call Set "strKey=HKLM\SOFTWARE\Microsoft\Window s\CurrentVersion\Uninstall\%ProductName%"
    >nul 2>&1 Reg.exe Query "%strKey%" &&(Set keyexist=True & Goto:endregsearch)
    Set /a i = i+1
    IF %i% LEQ 5 (
      echo\  [%i%] Key not present
      %wait% 600 seconds
     ) Else (
      echo\  [%i%] Key not present
      Set keyexist=False
    echo keyExist? = %keyexist%
    pause>nul & cls

    This posting is provided "AS IS" with no warranties, and confers no rights.


    ** Remember to give credit where credit's due **
    and leave Reputation Points for meaningful posts


    • #3
      Re: Batch file help

      hi, can you tell me what below statement will do?

      >nul 2>&1 Reg.exe Query "%strKey%" &&(Set keyexist=True & Goto:endregsearch)


      • #4
        Re: Batch file help

        Originally posted by charlsteve View Post
        >nul 2>&1 Reg.exe Query "%strKey%" &&(Set keyexist=True & Goto:endregsearch)
        Let's split the command for smaller chunks for easy an analysis.

        >nul 2>&1 : Redirect command output to null, so it won't print anything.
        Reg.exe Query "%strKey%" : Use the reg.exe program and look for the key. Its value is stored in a variable to improve readability.
        &&(Set keyexist=True & Goto:endregsearch) : If last command was successful, set the keyExist variable to true and go to label :endRegSearch.