Skip to content

Instantly share code, notes, and snippets.

@Dillie-O
Created November 5, 2021 16:07
Show Gist options
  • Save Dillie-O/f7d06785b6a4355d231ff69eb789366a to your computer and use it in GitHub Desktop.
Save Dillie-O/f7d06785b6a4355d231ff69eb789366a to your computer and use it in GitHub Desktop.
[Run Apps As User] Launch an application as a different user (helpful with VPN users) #command #runas #batch
@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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment