I'm making a script to launch SQL Server Management Studio
using runas
command on Windows
machine. When ran from cmd
the command prompts user to enter the password and then starts the program.
from subprocess import Popen, PIPE
user = '/user:some_domain\\username' # \ to escape special character
path = 'C:/Program Files (x86)/Microsoft SQL Server/130/Tools/Binn/ManagementStudio/Ssms.exe'
process = Popen(['runas', '/netonly', user, path], stdin=PIPE, stdout=PIPE) # launches 'ssms.exe'
process.communicate('password\n') # never hit
In my case as soon as it hits the process = Popen(...)
line it launches the SSMS
without ever prompting for the password. Checking process in Windows Task Manager
shows the same username in both cases, so I don't know if it's running on the correct domain. How can I address this?