' ****************************************************** ' * ' * Name: runas-ssms.vbs ' * ' * Design Phase: ' * Author: John Miner ' * Date: 05-02-2012 ' * Purpose: Run the SSMS program under different ' * credentials. ' * ' ******************************************************/ '-- '-- 1 - Get user account '-- '-- Ask for the user account Dim strUser strUser = InputBox("Please enter the user account: ", "User", , 100, 200) '-- See you later If strUser = "" Then WScript.Echo "User cancelled the script." WScript.Quit End If '-- '-- 2 - Get user password '-- '-- Ask for the password Dim strPwd strPwd = InputBox("Please enter the password: ", "Password", , 100, 200) '-- See you later If strPwd = "" Then WScript.Echo "User cancelled the script." WScript.Quit End If '-- '-- 3 - Run the program under credentials '-- '-- Create a command shell Dim objShell Set objShell= Wscript.CreateObject("WScript.Shell") '-- Full path to program Dim strPath strPath = "C:\Program Files\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\Ssms.exe" '-- Create full command dim strCmd strCmd = "runas /user:" & strUser & space(1) & chr(34) & strPath & chr(34) '-- Run as command under the account objShell.Run strCmd, 2 WScript.Sleep 100 '-- Send keys for password objShell.Sendkeys strPwd & "~" Wscript.Quit