@echo off setlocal enabledelayedexpansion :: Unpack arguments for %%a in (%*) do set "%%a=1" set app_path=%1 if NOT "%escalate%" == "1" goto skipEscalate :: This enables tracy sampling by running the executable in administrator mode. :: BatchGotAdmin :: https://stackoverflow.com/a/10052222 :------------------------------------- :: --> 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" :-------------------------------------- :skipEscalate :: `ping` is being used in place of `TIMEOUT` :: https://www.ibm.com/support/pages/timeout-command-run-batch-job-exits-immediately-and-returns-error-input-redirection-not-supported-exiting-process-immediately taskkill /im tracy-profiler.exe /f 2> nul start tracy-capture.exe -o .tracy -f echo Launching app "%app_path%"... %app_path% if NOT %errorlevel% == 0 ( echo. echo Program failed pause exit /b 1 ) :: Give time for trace file to finish before opening tracy ping -n 2 127.0.0.1 >NUL echo Launching tracy... start "" "tracy-profiler.exe" ".tracy"