Jump to content

Need a little Batch help.


Recommended Posts

HI,

I did a little script but i'm stuck at the stage where the script should checks if a registry entry exists and if one exists then the script should add the additional registry keys. Everything works except this check thing. :}

SETLOCALSET SC=HKLM\SOFTWARE\ClassesSET Extn=3g2-0 3ga-0 3gp-0 3gp2-0 3gpp-0 aac-0 ac3-0 aif-0 aifc-0 aiff-0 alac-0 amr-0 amv-0 aob-0 ape-0 apl-0for %%j in (%Extn%) do (  for /f "tokens=1,2 delims=-" %%a in ("%%j") do (    REG QUERY "%SC%\ixhplayerg.%%a" 1>NUL    IF "%ERRORLEVEL%"=="0" do (      REG ADD "%SC%\ixhplayerg.%%a\shell\enqueue" /ve /t REG_SZ /d "Add to IXH Playlist" /f 1>NUL      REG ADD "%SC%\ixhplayerg.%%a\shell\enqueue" /v "Icon" /t REG_SZ /d "\"%ProgramFiles%\KMedia Player\ixh.exe\",%%b" /f 1>NUL      REG ADD "%SC%\ixhplayerg.%%a\shell\enqueue\command" /ve /t REG_SZ /d "\"%ProgramFiles%\KMedia Player\ixh.exe\" \"/add %%1\"" /f 1>NUL      REG ADD "%SC%\ixhplayerg.%%a\shell\open" /ve /t REG_SZ /d "Play with IXH" /f 1>NUL      REG ADD "%SC%\ixhplayerg.%%a\shell\open" /v "Icon" /t REG_SZ /d "\"%ProgramFiles%\KMedia Player\ixh.exe\",%%b" /f 1>NUL    )  ))ENDLOCAL
Edited by Outbreaker
Link to comment
Share on other sites


At first sight you are missing the ENABLEDELAYEDEXPANSION, variables inside a FOR loop are not updated unless you use it:

http://www.robvanderwoude.com/variableexpansion.php

Try changing to !Errorlevel!, and in any case when experimenting you shouldn't redirect the output to NUL, as this way you cannot actually see what is happening, as a matter of fact I would add some more "troubleshooting useful" commands (that you can later remove, once satisfied with result), *like*:

SETLOCAL ENABLEDELAYEDEXPANSION....ECHO "%SC%\ixhplayerg.%%a"PAUSEREG QUERY "%SC%\ixhplayerg.%%a" IF "!ERRORLEVEL!"=="0" do (ECHO Errorlevel is 0....
jaclaz
Link to comment
Share on other sites

I did everything you said but i still get this error:

HKEY_LOCAL_MACHINE\SOFTWARE\Classes\ixhplayerg.apl\shell

'do' is not recognized as an internal or external command,

operable program or batch file.

Press any key to continue . . .

Which you DID NOT report initially. :whistle:

jaclaz

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...