Pergunta

I have modified my right-click menu using the registry to launch a batch file this works a charm however My batch file comprises of sub routines using the GOTO function. is it possible to launch the batch file and skip to a specific goto command using the registy example given below?

the following is my code to launch the batch (which works):

 Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\*\shell\MakeSomethingUp2\]
@="START SUB-COMMAND 1"

[HKEY_CLASSES_ROOT\*\shell\MakeSomethingUp2\command]
@="\"C:\\MY_BATCH_PROGRAM.bat\" \"%1\""
Foi útil?

Solução

If your batch file accepts only one parameter, you could use the second one to denote whether you want to run the main part or a subroutine (and which one, too).

More specifically, here's how you could do:

@ECHO OFF
IF "%2" == "sub1" GOTO sub1
IF "%2" == "sub2" GOTO sub2

:: otherwise just get on with the main part
...

:sub1
...

:sub2
...

Now you could specify in the registry file something like this:

@="\"C:\\MY_BATCH_PROGRAM.bat\" \"%1\" sub1"
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top