DEV Community

Cover image for Start All Your DEV Programs in one Shortcut on Windows 10
Serzhan Akhmetov
Serzhan Akhmetov

Posted on

Start All Your DEV Programs in one Shortcut on Windows 10

If you're like me - god help us - then you have this constant itch to automate every single part of your existence. The following two scripts will give a blueprint for creating your own start-my-dev-environment scripts.

Step 1 - Launching apps in batch file

We'll be launching 3 programs:

  • Spotify
  • Chrome
  • Visual Studio Code

additionally, we'll start an OpenVPN client connection.

You'll want to create a batch file like so:

@ECHO OFF
tasklist /FI "IMAGENAME eq Spotify.exe" 2>NUL | find /I /N "Spotify.exe">NUL
if NOT "%ERRORLEVEL%" == "0" start "spotify_play_lofi-playlist.vbs" "C:\Users\<username>\Documents\batch_scripts\spotify_play_lofi-playlist.vbs" && TIMEOUT 5

tasklist /FI "IMAGENAME eq chrome.exe" 2>NUL | find /I /N "chrome.exe">NUL
if NOT "%ERRORLEVEL%" == "0" start "chrome.exe" "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"

start " " "C:\Program Files\OpenVPN\bin\openvpn-gui.exe" --command disconnect_all
start "openvpn-gui.exe" "C:\Program Files\OpenVPN\bin\openvpn-gui.exe" --connect my_conf.ovpn

tasklist /FI "IMAGENAME eq Code.exe" 2>NUL | find /I /N "Code.exe">NUL
if NOT "%ERRORLEVEL%" == "0" start "Code" "C:\Users\<username>\AppData\Local\Programs\Microsoft VS Code\Code.exe"

Here, the tasklist commands are there to make sure we don't run a second instance of an app. For OpenVPN, it's easier to just reconnect.

Step 2 - Spotify Autoplay Script

The spotify VB script is there to launch Spotify and start a playlist in shuffle mode. Save it in the same folder as your batch script, for safekeeping.

Set WshShell = WScript.CreateObject("WScript.Shell")
Comandline = "C:\Users\<username>\AppData\Roaming\Spotify\Spotify.exe"
WScript.sleep 500
CreateObject("WScript.Shell").Run("spotify:playlist:74sUjcvpGfdOvCHvgzNEDO")
WScript.sleep 3000
WshShell.SendKeys " "
WScript.sleep 100
WshShell.SendKeys "^{RIGHT}"

You can get the playlist URI by right-clicking the playlist > Share > Copy Spotify URI.

Step 3 - Shortcut Placement

This is simple, create a shortcut to your batch file and place it in your Start Menu Programs folder (%ProgramData%\Microsoft\Windows\Start Menu\Programs). You may then move it to the quick-launch bar if you wish.

References

Top comments (0)