sql server - using runas with a password and a sql command -


i have batch file following script (which found here @ stackoverflow)

@if (@codesection == @batch) @then @echo off start runas "/user:domain\username" "cmd.exe" cscript //nologo //e:jscript "%~f0" goto :eof @end wscript.createobject("wscript.shell").sendkeys("mypass{enter}"); 

where mypass username's password.

this works , new commandline window opens new user! problem need run sqlcmd parameter , can't find way write batch both things (open new window user command parameters)

the sql command:

"c:\program files\microsoft sql server\110\tools\binn\sqlcmd.exe" -s "my.server.com, 1234" -d "mydatabase" -e -b -q "exec mydatabase.[dbo].[mytable] @parameter=1" 

i tried moving whole sql command batch (mybatch.bat) file , change first batch this:

start runas "/user:domain\username" "mybatch.bat" 

but doesn't work.

any please?

runas /user:domain\user "cmd.exe /k c:\path\to\mybatch.bat test"

cmd /k keep console open after batch execution, or cmd /c close it


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -