The last modifications of this post were around 2 years ago, some information may be outdated!
Summary
For apps where we are connected to an environment via VPN, we may need to run the app as a different user than logged in. This batch file presents options to the user. You can edit to add more
Usage
run_app_as_user
Code
@ECHO off
cls
:start
ECHO.
ECHO 1. Visual Studio 2019
ECHO 2. VS Code
ECHO 3. Sql Server Management Studio
ECHO.
set choice=
set /p choice=Choose which application to launch:
if not '%choice%'=='' set choice=%choice:~0,1%
if '%choice%'=='1' goto vs
if '%choice%'=='2' goto vscode
if '%choice%'=='3' goto ssms
ECHO "%choice%" is not valid, try again
ECHO.
:vs
runas /noprofile /netonly /user:domain\userid "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\devenv.exe"
goto end
:vscode
runas /noprofile /netonly /user:domain\userid "C:\Users\SeanPatterson\AppData\Local\Programs\Microsoft VS Code\Code.exe"
goto end
:ssms
runas /noprofile /netonly /user:domain\userid "C:\Program Files (x86)\Microsoft SQL Server Management Studio 18\Common7\IDE\Ssms.exe"
goto end
:end