You are not logged in.
Is it possible to use a parameter to launch your batch file which then will goto a routine part? Im not sure if that is worded right, but heres the example
c:\myscript.cmd
:one
echo 1
more stuff
exit
:two
echo 2
more stuff
exit
:three
echo 3
more stuff
exit
start->run
c:\myscript.cmd "two"
output will be echo 2, more stuff, exit
hope you know what i mean, thanks, and is it possible to do this?
cmd, vbs, ps, bash
autoit, python, swift
Offline
All you need is a goto
@echo off
goto %1
goto sub_error
:one
echo 1
more stuff
exit
:two
echo 2
more stuff
exit
:three
echo 3
more stuff
exit
goto :eof
:sub_error
echo none matched
To be extra sure the labels dont randomly match some other text in the script I usually add a prefix
like
:label_one
then you do
goto label_%1
Offline
That was nice, it still crashed if it didnt have a parameter when you launched it, but thats ok
cmd, vbs, ps, bash
autoit, python, swift
Offline
^ Ah of course you need to start it with something like
if "%1"=="" goto sub_error
goto %1
Offline