using runas with a password and a sql command

I have a batch file with the following script (which i found here at stackoverflow)

@if (@CodeSection == @Batch) @then
@echo off
start runas "/user:domain\username" "cmd.exe"
CScript //nologo //E:JScript "%~F0"
goto :EOF

where mypass is the username's password.

this works perfectly and a new commandline window opens as the new user! the problem is that i now need to run an sqlcmd with parameter and I can't find any way to write a batch that does both things together (open the new window as another user together with the command with parameters)

the sql command:

"C:\Program Files\Microsoft SQL Server\110\Tools\Binn\SQLCMD.EXE" -S ", 1234" -d "myDataBase" -E -b -q "EXEC myDataBase.[dbo].[myTable] @parameter=1"

I tried moving the whole sql command to another batch (myBatch.bat) file and change the first batch to this:

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

but it doesn't work.

any help please?


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

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

Need Your Help

How to write an "OR" within a Linq to Sql .Where()

c# linq linq-to-sql where

I want to get all records WHERE (s.override == 1 OR (s.override == 2 AND s.approved == 1))