#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2009
    Posts
    103
    Rep Power
    16

    Batch file to evaluate value in regestry


    Hey,

    I need to evaluate this regestry value

    Code:
    reg query "HKCU\Control Panel\International" /v "sCountry" | find /i "Canada"

    If the returned value is not Canada i need it to run

    Code:
    start: http://intranet/error.cfm
    I'm new to writing batch files so i'm sure this is just an IF statement but i'm unsure of the syntax and how to tie it in with the reg query error level.

    This is what i have now but it does not work and i'm not sure i've got the ifstatement right.... it looks right but i'm new so.

    Code:
    @echo offsCountry
    reg query "HKCU\Control Panel\International" /v "sCountry" | find /i "Canada" > output.txt
    
    if errorlevel 1 goto not_exist
    goto exit
    
    :not_exist
    start: http://intranet/error.cfm
    Any help would be great.

    Thanks.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2009
    Posts
    103
    Rep Power
    16
    Originally Posted by dsfx
    Hey,

    I need to evaluate this regestry value

    Code:
    reg query "HKCU\Control Panel\International" /v "sCountry" | find /i "Canada"

    If the returned value is not Canada i need it to run

    Code:
    start: http://intranet/error.cfm
    I'm new to writing batch files so i'm sure this is just an IF statement but i'm unsure of the syntax and how to tie it in with the reg query error level.

    This is what i have now but it does not work and i'm not sure i've got the ifstatement right.... it looks right but i'm new so.

    Code:
    @echo offsCountry
    reg query "HKCU\Control Panel\International" /v "sCountry" | find /i "Canada" > output.txt
    
    if errorlevel 1 goto not_exist
    goto exit
    
    :not_exist
    start: http://intranet/error.cfm
    Any help would be great.

    Thanks.
    Never mind, turns out the error was with the way i was testing this. It does work.

    Thanks

IMN logo majestic logo threadwatch logo seochat tools logo