TransWikia.com

Batch file to open Steam shortcuts not working

Arqade Asked by Nader on July 9, 2021

I created a batch file to pick a random file from a folder. This includes steam games as URL shortcuts but the games fail to read Steam and end up crashing because they lack a connection to their DRM.
The code:

@echo off & setlocal
 :: start of main
 :letsago
 rem Set your path here:
 set "workDir=C:UsersNaderDesktopGaming"
 rem Set the name of the file here:
 set "name=Random.bat"

 set /a "rdm=%random%"

 rem Push to your path.
 pushd "%workDir%"

 rem Count all files in your path. (dir with /b shows only the filenames)
 set /a "counter=0"
 for /f "delims=" %%i in ('dir /b ^|find "."') do call :sub1

 rem This function gives a value from 1 to upper bound of files
 set /a "rdNum=(%rdm%*%counter%/32767)+1"

 rem Start a random file
 set /a "counter=0"
 for /f "delims=" %%i in ('dir /b ^|find "."') do set "fileName=%%i" &call :sub2

 rem Pop back from your path.
 popd "%workDir%"
 echo Closing in 5 seconds...
 ping -n 6 -w 1000 127.0.0.1 > nul
 goto :eof
 :: end of main

 :: start of sub1
 :sub1
 rem For each found file set counter + 1.
 set /a "counter+=1"
 goto :eof
 :: end of sub1

 :: start of sub2
 :sub2
 rem 1st: count again,
 rem 2nd: if counted number equals random number then start the file.
 set /a "counter+=1"
 if %counter%==%rdNum% (start "" "%fileName%" &echo Starting %fileName%)

 goto :eof
 :: end of sub2

3 Answers

Just make a desktop shortcut for the steam game then copy the link finally add the link to this code.

start "" "(Your Link)"

It works for me.

Answered by user91602 on July 9, 2021

This is working in registry and .bat file:

start "" "C:Program Files (x86)SteamSteam.exe" steam://rungameid/322330

Answered by Lesenus on July 9, 2021

I've not used BAT in years so I can't really help with a script, but there is an easier way to do this:

  • Find the Steam Library Folders that you want to randomly launch apps from (include in a list of random folder options?) and scrape the names of all of the files with the extension ".acf" from it. These are Steam's appmanifest files which contain some of the data & settings for installed apps, and have a name format like appmanifest_#.acf where the # is the Steam appid of the app, which is unique for every app and is needed for the next part.

  • When a Steam app is selected to be launched (noticeable to the script because of the appmanifest_ part of the file name) extract the appid from the file name (only the number portion, not the appmanifest_ part, and of course not the extension) and then launch Steam with a command-line argument using something like C:Program Files (x86)SteamSteam.exe -applaunch # where # is the appid to launch.

This will start Steam and have it launch the game for you, so there should be no issues with any games not finding the client.

Answered by l3l_aze on July 9, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP