Outbreaker Posted November 17, 2013 Share Posted November 17, 2013 (edited) 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 November 17, 2013 by Outbreaker Link to comment Share on other sites More sharing options...
jaclaz Posted November 17, 2013 Share Posted November 17, 2013 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.phpTry 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 More sharing options...
Outbreaker Posted November 17, 2013 Author Share Posted November 17, 2013 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 . . . Link to comment Share on other sites More sharing options...
Guest Posted November 17, 2013 Share Posted November 17, 2013 (edited) DO is not to be used in IF statements. More information on using "IF ERRORLEVEL" can be found on ss64.com. Try: IF !ERRORLEVEL! EQU 0 ( Edited November 17, 2013 by 5eraph Link to comment Share on other sites More sharing options...
jaclaz Posted November 17, 2013 Share Posted November 17, 2013 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. jaclaz Link to comment Share on other sites More sharing options...
Outbreaker Posted November 17, 2013 Author Share Posted November 17, 2013 (edited) Thanks guys everything is now working with "IF !ERRORLEVEL! EQU 0 (" . Edited November 17, 2013 by Outbreaker Link to comment Share on other sites More sharing options...
jaclaz Posted November 17, 2013 Share Posted November 17, 2013 Thanks guys everything is now working with "IF !ERRORLEVEL! EQU 0 (" . Good. jaclaz Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now