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
 General SQL Server Forums
 Script Library
 script start up accounts

Author  Topic 

mherfkens
Starting Member

8 Posts

Posted - 2004-02-17 : 18:54:01
Is it possible to write a T-SQL scripts to change the accounts that run the SQLExec service and the SQL Agent service? If so how?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-02-17 : 18:58:28
If you can do it from a cmd window using a DOS command, then you can use xp_cmdshell to make the change using T-SQL. xp_cmdshell can run any DOS command. You'll need sysadmin privileges to run the extended stored procedure. Here is an example of its use:

EXEC master.dbo.xp_cmdshell 'DIR C:\Temp\'

Tara
Go to Top of Page

claire
Starting Member

19 Posts

Posted - 2004-02-25 : 10:44:59
Not exactly, xp_cmdshell is not so powerful as Command prompt. Like Calc.exe, you could call from commnand prompt, but wont work in xp_cmdshell
Go to Top of Page

mherfkens
Starting Member

8 Posts

Posted - 2004-02-25 : 11:04:15
So Claire, what is your suggested method?
Go to Top of Page

ditch
Master Smack Fu Yak Hacker

1466 Posts

Posted - 2004-02-25 : 12:01:56
quote:
Originally posted by claire

Not exactly, xp_cmdshell is not so powerful as Command prompt. Like Calc.exe, you could call from commnand prompt, but wont work in xp_cmdshell



I'm not sure why someone would want to do this though.


Duane.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-02-25 : 12:19:23
quote:
Originally posted by claire

Not exactly, xp_cmdshell is not so powerful as Command prompt. Like Calc.exe, you could call from commnand prompt, but wont work in xp_cmdshell



I'm not sure what the point of calling calc.exe from xp_cmdshell would be.


mherfkens, use xp_cmdshell for this. It's the only way with T-SQL to do what you want. You just need to figure out which cmd commands you'll need.

Tara
Go to Top of Page

mherfkens
Starting Member

8 Posts

Posted - 2004-02-25 : 12:25:37
Well I most definately don't want to open calc, I just want to move some files or kick off a batch file. After the post from Tara I set ip up to start the SQL Agent, it works great.

I just need to finish creating a script that I can give to domain admins to run on SQL Servers that will grant me access and if I can figure out all the details I'd like it to set up jobs for each existing database. I'm just not doing so well scripting it to pull the database names from the system tables and create jobs for all the user databases.
Go to Top of Page

claire
Starting Member

19 Posts

Posted - 2004-02-25 : 13:20:44
It's nothing about the point. But just keep the concept that T-SQL xp_cmdshell cannot be treated the same as command prompt.
Go to Top of Page
   

- Advertisement -