Run a program as administrator using .BAT file

IT-CICA
IT-CICA used Ask the Experts™
on
Hi

I have a SSIS package in which one of the steps is Execute Task -> execute a .BAT file and launch a program (Street sweeper).

The package runs successfully when run through Visual studio. The program runs fine when only the .BAT file is run.

But a job that executes this package, it gets stuck at this .BAT file step because the program needs to be run as administrator. (There is no 'Run as Admin' check box on the properties of .BAT file) I created a shortcut to this file, configured the shortcut to always run as admin, but the SSIS package's job still fails at this step.
I need to come up with something to always run this program as administrator through the BAT file.

Any workarounds to this?

Thanks in advance!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Hi,
Try this by adding the below line in your batch file:

runas /user:REQUIREDUSERNAME /savecred filenamewithfullpath

Commented:
Another way is to install the program in c:\

That would avoid needing Administrator rights in \program files when batch file is ran
Database Analyst
Commented:
"But a job that executes this package, it gets stuck at this .BAT file step because the program needs to be run as administrator. "

Which "...program needs to be run as administrator. "

Think that your SQL Agent service starts under some NT account and THAT is the account that needs sufficient permissions to run it all - same as the NT account that was able to "...runs successfully when run through Visual studio."

Author

Commented:
Thanks

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial