Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
Ed Dyreen
- Expert
- Posts: 1569
- Joined: 16 May 2011 08:21
- Location: Flanders(Belgium)
-
Contact:
#16
Post
by Ed Dyreen » 23 Feb 2019 09:10
Nicodemus wrote: ↑23 Feb 2019 08:42
thank you for your help. this works so im happy but I want to learn. how would I make it into a single batch file?
Code: Select all
@echo off
for /F "tokens=3 delims=:" %%? in (
"%~0"
) do if %%? EQU getParams (
start "" "E:\LaunchBox\Games\Big Fish Games\Launchers\Blackie.exe"
start "my game" /WAIT "E:\12noon Display Changer\dc64.exe" -width=1280 -height=720 /c "E:\LaunchBox\Games\Big Fish Games\Mystery Case Files - Return to Ravenhearst FINAL\ReturnToRavenhearst.exe"
taskkill /IM Blackie.exe
exit 0
)
>nul break | ( start "" /MIN "%~d0\:getParams:\..\%~pnx0" )
::
exit 0
This is already a bit complex, to understand what is happening
read this
I wonder if this is the shortest way to do this actually, I'd be interested if someone else prop up a more elegant or efficient solution
-
aGerman
- Expert
- Posts: 4678
- Joined: 22 Jan 2010 18:01
- Location: Germany
#17
Post
by aGerman » 23 Feb 2019 09:30
Similar but using an additional argument:
Code: Select all
@echo off &setlocal
if "%~1" neq "__MINIMIZED__" (start /min cmd /c "%~f0" __MINIMIZED__ %*&exit /b)
shift /1
:: your code here:
echo I'm minimized.
pause
You still can't avoid the flashing window of the first instance. Consider to use a shortcut to your batch file where it would be just a setting ("Run" property).
Steffen
-
Ed Dyreen
- Expert
- Posts: 1569
- Joined: 16 May 2011 08:21
- Location: Flanders(Belgium)
-
Contact:
#18
Post
by Ed Dyreen » 23 Feb 2019 09:54
Ah yes, aGeman's is better, and can be even shorter because you do not even need args.
Code: Select all
@echo off &if "%~1" neq "MIN" start /MIN cmd /c "%~f0" MIN &exit /b
start "" "E:\LaunchBox\Games\Big Fish Games\Launchers\Blackie.exe"
start "my game" /WAIT "E:\12noon Display Changer\dc64.exe" -width=1280 -height=720 /c "E:\LaunchBox\Games\Big Fish Games\Mystery Case Files - Return to Ravenhearst FINAL\ReturnToRavenhearst.exe"
taskkill /IM Blackie.exe
exit 0
Thanks a, I knew I was forgetting something obvious
-
aGerman
- Expert
- Posts: 4678
- Joined: 22 Jan 2010 18:01
- Location: Germany
#19
Post
by aGerman » 24 Feb 2019 06:29
In case parameter handling or the content of cmdcmdline matters, you still can use a variable.
Code: Select all
if not defined __MINIMIZED__ set __MINIMIZED__=1&start /min cmd /c "%~f0" %*&exit /b
Steffen
-
Nicodemus
- Posts: 9
- Joined: 22 Feb 2019 12:58
#20
Post
by Nicodemus » 25 Feb 2019 16:40
thanks for everyone's help, I learned a lot.