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
Post a Comment