September 23, 2005 at 6:25 am
I have created a script file(schd.vbs) with below content
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run(http://www.yahoo.com)
---------
When I try the below command in Query Analyser I am not getting any result(its showing 'executing Query batch')
exec master.dbo.xp_cmdshell 'C:\schd.vbs'
Note:
1.The script file is available both in client and Sqlserver machine
2.When I double click the script file the functionality is working
3. This is the link 'http://www.eggheadcafe.com/articles/20010426.asp' from where i got this idea
I need help
September 23, 2005 at 12:24 pm
two issues here. first, you forgot to quote the url, so if you tested the vbs file from a command prompt to see if it works, you'd see it errors out.
xp_command shell will return any number of nvarchar(255) rows of any text for each line that was returned from the command prompt.
Shelling out an html file does not return any text.
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run("http://www.yahoo.com")
and then try
exec master.dbo.xp_cmdshell 'C:\schd.vbs'
NULL
--nothing will show up
but try this:
exec master.dbo.xp_cmdshell 'DIR *.txt'
and you get something like:
Volume in drive C has no label.
Volume Serial Number is 8065-89E4
NULL
Directory of C:\WINNT\system32
NULL
06/20/2003 09:00a 38,082 EULA.TXT
05/31/1998 01:00a 2,819 MSOracle32Readme.txt
06/17/1998 01:00a 12,141 SQLSRDME.TXT
04/24/1998 01:00a 11,923 VFPODBC.TXT
10/27/2004 08:22a 885 vscontents.txt
5 File(s) 65,850 bytes
0 Dir(s) 3,660,854,272 bytes free
NULL
Lowell
September 25, 2005 at 10:26 pm
1.When i executed the vbs file from command prompt I am not getting any errors,not only that the script file is working and I am getting the yahoo page which i had specified in the script file
2. But when i try this "exec master.dbo.xp_cmdshell 'C:\schd.vbs' " in query analyser, the text output is null. But it is supposed to show me the yahoo page which i had specified in the script file. When I execute this in Query analyser the analyser gets hanged.
October 3, 2005 at 12:17 am
What account(s) are you using for the SQL Server and SQL Server Agent services? If you're not using LocalSystemAccount with 'Allow service to interact with desktop' enabled, then you'll never see the page that is launched.
This is normal behaviour for a server because users don't sit at the server and interact with the desktop.
If you put a delay in your script file, you'll probably be able to see the process in Task Manager. If you do this, be aware that you won't be able to respond to any messages or propmts, so you might need to kill the process manually.
--------------------
Colt 45 - the original point and click interface
October 3, 2005 at 5:08 am
Shelling out an html file does not return any text.
if your objective is to use sql server to call and parse a web page, you will need to write an application that uses the wininet.dll to open a page; with that and the filesystemobject, you should be able to insert the text into some table and you could manipulate the text from there.
what are you trying to accomplish?
Lowell
October 6, 2005 at 12:41 pm
The SQL command should be exec master.dbo.xp_cmdshell 'CScript C:\schd.vbs'
Norman
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply