Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista Tutorial - Starting SQL Server Agent Job

Reply
 
Old 06-23-2009   #1 (permalink)
Jeff C
Guest


 
 

Starting SQL Server Agent Job

I am trying to buid a script to be used by a person at their desktop machine
to execute a SQL Server Agent job on the server.

I need help sorting out the syntax of a VBS script I found that will do the
job. Any assistance/suggestions appreciated greatly.

2 questions on the script below:

1. ("SQLDMO.SQLServer") should it be (nameofSQLServer.SQLServer)?

2. Using Windows Authentication: can oServer.Connect(".", "user",
p@xxxxxx) be oServer.Connect("nameofSQLServer.SQLServer)??

Dim oJob, oServer

' Creates the SQLDMO SQL Server object

oServer = CreateObject("SQLDMO.SQLServer")

oServer.Connect(".", "user", p@xxxxxx)

' Then Obtains the job to start

oJob = oServer.JobServer.Jobs("MyJob")

' Start the job.

Call oJob.Start()


Thanks in advance

--
Jeff C
Live Well .. Be Happy In All You Do

My System SpecsSystem Spec
Old 06-23-2009   #2 (permalink)
Richard Mueller [MVP]
Guest


 
 

Re: Starting SQL Server Agent Job


"Jeff C" <JeffC@xxxxxx> wrote in message
news:89ABF7DC-C561-4C58-B437-B9EA8DD1E0C3@xxxxxx
Quote:

>I am trying to buid a script to be used by a person at their desktop
>machine
> to execute a SQL Server Agent job on the server.
>
> I need help sorting out the syntax of a VBS script I found that will do
> the
> job. Any assistance/suggestions appreciated greatly.
>
> 2 questions on the script below:
>
> 1. ("SQLDMO.SQLServer") should it be (nameofSQLServer.SQLServer)?
>
> 2. Using Windows Authentication: can oServer.Connect(".", "user",
> p@xxxxxx) be oServer.Connect("nameofSQLServer.SQLServer)??
>
> Dim oJob, oServer
>
> ' Creates the SQLDMO SQL Server object
>
> oServer = CreateObject("SQLDMO.SQLServer")
>
> oServer.Connect(".", "user", p@xxxxxx)
>
> ' Then Obtains the job to start
>
> oJob = oServer.JobServer.Jobs("MyJob")
>
> ' Start the job.
>
> Call oJob.Start()
>
>
> Thanks in advance
>
> --
> Jeff C
> Live Well .. Be Happy In All You Do
I'm not familiar with the SQLDMO provider. See this link for connection
strings:

http://www.connectionstrings.com/

When using Windows Integrated Authentication I use "Trusted_Connection=Yes"
in the connection string in place of user name and password. In your
example, the "." undoubtedly means the current computer. If your server is
called "MyServer", you would use "MyServer" to connect to the default
instance. If you have a named instance, for example "MyInstance", use
"MyServer\MyInstance".

A search on SQLDMO gave me the links below, which might prove more useful:

http://www.sqldev.net/sqldmo/SQL-DMO-FAQ.htm

http://www.sqlteam.com/article/introduction-to-sql-dmo

From the last link I believe you want to use:

Set oServer = CreateObject("SQLDMO.SQLServer")
oServer.loginsecure = True
oServer.Connect("MyServer")

where "MyServer" is the name of your server (if there no named instance). I
have no idea how to start a job, but I suspect it should be:

Set oJob = oServer.JobServer.Jobs("MyJob")

where "MyJob" is the name of a job.

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


My System SpecsSystem Spec
Old 06-23-2009   #3 (permalink)
Jeff C
Guest


 
 

Re: Starting SQL Server Agent Job

Thanks Richard - the references and your info did the trick!
--
Jeff C
Live Well .. Be Happy In All You Do


"Richard Mueller [MVP]" wrote:
Quote:

>
> "Jeff C" <JeffC@xxxxxx> wrote in message
> news:89ABF7DC-C561-4C58-B437-B9EA8DD1E0C3@xxxxxx
Quote:

> >I am trying to buid a script to be used by a person at their desktop
> >machine
> > to execute a SQL Server Agent job on the server.
> >
> > I need help sorting out the syntax of a VBS script I found that will do
> > the
> > job. Any assistance/suggestions appreciated greatly.
> >
> > 2 questions on the script below:
> >
> > 1. ("SQLDMO.SQLServer") should it be (nameofSQLServer.SQLServer)?
> >
> > 2. Using Windows Authentication: can oServer.Connect(".", "user",
> > p@xxxxxx) be oServer.Connect("nameofSQLServer.SQLServer)??
> >
> > Dim oJob, oServer
> >
> > ' Creates the SQLDMO SQL Server object
> >
> > oServer = CreateObject("SQLDMO.SQLServer")
> >
> > oServer.Connect(".", "user", p@xxxxxx)
> >
> > ' Then Obtains the job to start
> >
> > oJob = oServer.JobServer.Jobs("MyJob")
> >
> > ' Start the job.
> >
> > Call oJob.Start()
> >
> >
> > Thanks in advance
> >
> > --
> > Jeff C
> > Live Well .. Be Happy In All You Do
>
> I'm not familiar with the SQLDMO provider. See this link for connection
> strings:
>
> http://www.connectionstrings.com/
>
> When using Windows Integrated Authentication I use "Trusted_Connection=Yes"
> in the connection string in place of user name and password. In your
> example, the "." undoubtedly means the current computer. If your server is
> called "MyServer", you would use "MyServer" to connect to the default
> instance. If you have a named instance, for example "MyInstance", use
> "MyServer\MyInstance".
>
> A search on SQLDMO gave me the links below, which might prove more useful:
>
> http://www.sqldev.net/sqldmo/SQL-DMO-FAQ.htm
>
> http://www.sqlteam.com/article/introduction-to-sql-dmo
>
> From the last link I believe you want to use:
>
> Set oServer = CreateObject("SQLDMO.SQLServer")
> oServer.loginsecure = True
> oServer.Connect("MyServer")
>
> where "MyServer" is the name of your server (if there no named instance). I
> have no idea how to start a job, but I suspect it should be:
>
> Set oJob = oServer.JobServer.Jobs("MyJob")
>
> where "MyJob" is the name of a job.
>
> --
> Richard Mueller
> MVP Directory Services
> Hilltop Lab - http://www.rlmueller.net
> --
>
>
>
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
agent.exe? Vista General
security package 'kerberos' not starting for server side - what? Vista performance & maintenance
ms agent PowerShell
Starting MCE 'Live TV' as default Screen when starting after Sleep Vista General
Accessing a Linux server behind a BBI Agent Router/Firewall Vista networking & sharing


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46