0

Working on a startup File (like a shortcut with special functions) for a game. (Counter-Strike Global Offensive)

The intention is to replace the menu music - some updates ago this was easier but right now I need to forging on a Batch file.

This is how it looks so far

@Echo off
"C:\Users\Cedo\Desktop\csgo\csgo\Counter-Strike Global Offensive.url"
Timeout 9
"C:\Users\Cedo\Desktop\csgo\csgo\csgomusic.m3u8"
[Timeout 240]!
[Taskkill /IM winamp.exe]! ----> Dont work! 
Exit

and the way to here is more complicated than I thought. I solved already a lot of problems because a lot of the stuff on the internet seems outdated I guess.

The actual problem is a second timeout and taskkill for the winamp music file. Strangely when inserting a second timeout (like the first) nothing happens. Just after closing winamp manually the Timer starts!

But something needs to be done so that the second timeout with 240 secs and the taskkill to close winamp automatically works.

Another cool thing would be to start the winamp music file a bit later without minimizing the started game window. (Already tried start /min commands - it doesn't matter actually - wont work if minimized or maximized) Does someone know more? Right now I'm good with 9 Seconds(winamp opens before the game maximizes because this takes some time and so i didn`t get tabbed out).

And is there maybe a better way to build this up or improve things?

Mooble
  • 3
  • 3
  • 2
    Use "start ...m3u8" to run it in background – Thomas Weller Dec 11 '19 at 20:41
  • Hey thats the way it should be(and is shown in many threads) but start without "" between the location and start( yes two of these `"´ so it looks like start "" "C:\...") just opens an empty cmd window named after the file. With those "" the program starts like i write it in my thread above... so just the location. – Mooble Dec 11 '19 at 20:54
  • Mooble, as the comment above your does not indicate a tendency to formatted text, please take it to be `start ...m3u8` and infer that the `start` command is what they're indicating is the solution. A quick look at the command prompt help, will show you the usage and options available. Essentially, if you're going to be doublequoting your file paths, _(which I would recommend as standard practice)_, you should use `Start "any or no Title between these doublequotes" /AnyOtherOptions "C:\Users\Cedo\Desktop\csgo\csgo\csgomusic.m3u8"`. – Compo Dec 11 '19 at 21:26

1 Answers1

0

Just after closing winamp manually the Timer starts!

Given this statement I infer that "C:\Users\Cedo\Desktop\csgo\csgo\csgomusic.m3u8" is starting Winamp.

Note place the following script into the "C:\Users\Cedo\Desktop\csgo\csgo\" folder, or update the "_RootFolder" to have the correct path.

So essentially what you need to do is this:

Start a separate command window to run the task to kill winamp, because otherwise you will only move on tot the next command when Winamp is killed manually.

@(SETLOCAL 
  REM SET "KillCmd="%~f0" :Kill_Winamp"
  REM SET "_StartKillCMD=start "Kill Winamp!" cmd /c %KillCmd%"
  SET "_StartKillCMD=start "Kill Winamp!" cmd /c "%~f0" :Kill_Winamp"
  SETLOCAL EnableDelayedExpansion
  ECHO OFF
  SET "eLvl=0"
  REM SET "_RootFolder=%USERPROFILE%\Desktop\csgo\csgo\"
  SET "_RootFolder=%~dp0"
  SET "CSGo_URL=!_RootFolder!Counter-Strike Global Offensive.url"
  SET "Music_File=!_RootFolder!csgomusic.m3u8"

  SET /A "_Timer_WinAmp_Start=9",   "_Timer_WinAmp_Kill= _Timer_WinAmp_Start + 240"

)

ECHO=%* | FIND /I ":Kill_Winamp" && (
  CALL :Kill_Winamp
) || (
  CALL :Main
)

( ENDLOCAL
  Exit /b %_eLvl%
}

:Main
  COLOR 2F
  ECHO=======================================================================
  ECHO=  Launching CSGO, Waiting %_Timer_WinAmp_Start% seconds before starting Winamp.
  ECHO=======================================================================
  ECHO=
  "%CSGo_URL%"
  ECHO=
  SETLOCAL DisableDelayedExpansion
   %_StartKillCMD%
  ECHO=
  ECHO=Started Kill Timer..
  ECHO=
  Timeout %_Timer_WinAmp_Start%
  "%Music_File%"
  ECHO=Exiting, Remove the pause on the next line if not needed.
  Pause
GOTO :EOF

:Kill_Winamp
  COLOR 4F
  ECHO=======================================================================
  ECHO=  Waiting %_Timer_WinAmp_Kill% Seconds before Killing Winamp.
  ECHO=======================================================================
  ECHO=
  ECHO=
  Timeout %_Timer_WinAmp_Kill%
  Taskkill /IM winamp.exe
  ECHO=Exiting, Remove the pause on the next line if not needed.
  Pause
GOTO :EOF
Ben Personick
  • 3,074
  • 1
  • 22
  • 29
  • Okay Thanks for your Reply, this is very cool :D - yes it starts winamp - But still got some issues like you mentioned - so i insert this and saved it as a .bat (i guess thats what you mean) Works fine when i run my shortcut except that the error appears that windows cannot find :kill_winamp - i`ll experiment a bit... right now im trying to create a second cmd file (that may be opened?)- is this the right way? Because starting another file is not so nice :/ – Mooble Dec 11 '19 at 21:59
  • okay try some things but got stucked... and when i open a second cmd window what should i do there... and what do you mean with a tot? – Mooble Dec 11 '19 at 22:34
  • .created a "Kill Winamp!.cmd" File thought that the line fromyour script - :Main with Start "Kill Winamp!" could be connected with an file but dont seems to work - any ideas? – Mooble Dec 11 '19 at 22:55
  • @Mooble Hey my bad I had an issue with Delayed Expansion, I copied some of my work from another script I use for a complex parallelized process and seem to have written entirely without delayed expansion. I just fixed it and proved it is working for myself. – Ben Personick Dec 12 '19 at 00:07
  • 1
    Okay Indeed - Works fine :) – Mooble Dec 12 '19 at 10:06