Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 Running dos batch script

Author  Topic 

mattys
Starting Member

2 Posts

Posted - 2008-10-02 : 00:56:28
Hi guys,

I am trying to run a Dos batch script from within SQL management studio.

Basically all it is trying to do is run a batch script located on the local drive C:\batch.bat

Settings are as follows

Type: Operating system (CmdExec)
Run as: SQL Agent Service Account.

I am unable to change the Run As user and it is throwing back a permssion issue.

Is anybody able to advise the correct way of running a batch script as an SQL job or how to change the Run as user so that it is using a domain account. It is being executed as the correct account but the actual running of the step is done by the SQL service account.

Thanks!

vhusain
Starting Member

7 Posts

Posted - 2008-10-02 : 02:41:29
Hi,

It is better to run it as xp_cmdshell. Try

http://blog.sqlauthority.com/2007/06/27/sql-server-running-batch-file-using-t-sql-xp_cmdshell-bat-file/

Regards
Go to Top of Page

YellowBug
Aged Yak Warrior

616 Posts

Posted - 2008-10-02 : 05:43:42
create a credential, with the domain user name and password
create a Operating System (CmdExec) SQL Server Agent proxy, using this credential
Configure the job step to run with this proxy.

What is the error you are getting? You may need sysadmin rights.
Go to Top of Page

mattys
Starting Member

2 Posts

Posted - 2008-10-02 : 22:23:26
Thanks YellowBug

That worked :)
Go to Top of Page
   

- Advertisement -