Skip to content

Instantly share code, notes, and snippets.

@ndrut
Last active July 11, 2022 20:26
Show Gist options
  • Save ndrut/30f7eb71f09273e34175396a3879b10d to your computer and use it in GitHub Desktop.
Save ndrut/30f7eb71f09273e34175396a3879b10d to your computer and use it in GitHub Desktop.
This windows batch file opens the steam game sea of thieves and sets cpu priority to maximum

Use

Right click raw to the right of startsot.bat and Save link as

Note: I created this to work around the fact that you can't use a real desktop shortcut to point to a real executable file for a game managed by steam.

Why does it ask for administrator privileges?

In order to set priority of a process you need administrator privileges (especially when setting above high)

@echo off
:: Ask for administrative privileges
:-------------------------------------
:: --> Check for permissions
IF "%PROCESSOR_ARCHITECTURE%" EQU "amd64" (
>nul 2>&1 "%SYSTEMROOT%\SysWOW64\cacls.exe" "%SYSTEMROOT%\SysWOW64\config\system"
) ELSE (
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
)
:: --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
echo Requesting administrative privileges...
goto UACPrompt
) else ( goto gotAdmin )
:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
set params= %*
echo UAC.ShellExecute "cmd.exe", "/c ""%~s0"" %params:"=""%", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
del "%temp%\getadmin.vbs"
exit /B
:gotAdmin
pushd "%CD%"
CD /D "%~dp0"
:--------------------------------------
:: Start Sea of Thieves (id: 1172620)
start steam://rungameid/1172620
:: Wait 15 seconds
timeout 15
:: Locate the Sea of Thieves Process and set its priority
:: Uses wmic https://docs.microsoft.com/en-us/windows/win32/wmisdk/wmic
wmic process where name="SoTGame.exe" call setpriority "realtime"
CALL :CHECK_FAIL
:CHECK_FAIL
@echo off
if NOT ["%errorlevel%"]==["0"] (
pause
exit /b %errorlevel%
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment