What are the steps to authorize use of ExecQuery inside a MSSQL Server
VBScript Job Step? For example:
Set oDmoSqlServer=CreateObject("SQLDMO.SqlServer2")
With oDmoSqlServer
.LoginSecure=True
.Name="(local)"
.Connect
End With
sds_DbSrvName=oDmoSqlServer.HostName
Set oDb=oDmoSqlServer.Databases("SomeDatabase","dbo")
Set oWMIServer=GetObject("winmgmts://./root/cimv2")
strSQL="Select * from Win32_LogicalDisk WHERE DriveType=3"
Set colItems=oWMIServer.ExecQuery(strSQL,"WQL",48)
For Each oItem in colItems
With oItem
sds_cDeviceID=.DeviceID
sds_cFileSystem=.FileSystem
sds_cFreeSpace=.FreeSpace
sds_cSize=.Size
sds_cSystemName=.SystemName
sds_cVolumeName=.VolumeName
sds_cVolumeSerialNumber=.VolumeSerialNumber
End WithI neglected to mention: the applicable server and sql agent accounts have:
Act as part of the operating system
Bypass traverse checking
Increase quotas
Lock pages in memory
Logon as a batch job
Logon as a service
Replace a process level token
What is missing?
"Mongo" <nospam@.nospam.com> wrote in message
news:eJOoVbCUFHA.3312@.TK2MSFTNGP09.phx.gbl...
> What are the steps to authorize use of ExecQuery inside a MSSQL Server
> VBScript Job Step? For example:
> Set oDmoSqlServer=CreateObject("SQLDMO.SqlServer2")
> With oDmoSqlServer
> .LoginSecure=True
> .Name="(local)"
> .Connect
> End With
> sds_DbSrvName=oDmoSqlServer.HostName
> Set oDb=oDmoSqlServer.Databases("SomeDatabase","dbo")
> Set oWMIServer=GetObject("winmgmts://./root/cimv2")
> strSQL="Select * from Win32_LogicalDisk WHERE DriveType=3"
> Set colItems=oWMIServer.ExecQuery(strSQL,"WQL",48)
> For Each oItem in colItems
> With oItem
> sds_cDeviceID=.DeviceID
> sds_cFileSystem=.FileSystem
> sds_cFreeSpace=.FreeSpace
> sds_cSize=.Size
> sds_cSystemName=.SystemName
> sds_cVolumeName=.VolumeName
> sds_cVolumeSerialNumber=.VolumeSerialNumber
> End With
>|||Hi Mongo,
You may have try execute the script via xp_cmdshell instead of running it
from Job.
Sincerely yours,
Michael Cheng
Microsoft Online Partner Support
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
========================================
=============
This posting is provided "AS IS" with no warranties, and confers no rights.sql
No comments:
Post a Comment