February 9, 2007 at 7:03 am
Hi, I have created a VBS file with the following code :;
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run("http://www.yahoo.com")
When I double click on this file it opens http://www.yahoo.com but when I execute exec xp_cmdshell 'c:\Name.vbs' in Query Analyzer nothing happens and the output is 'NULL'.
I want to run this VBS file through SQL and get the desire output. I am logged in as 'SA' and get the result when I type exec xp_cmdshell 'dir c:\'.
Please help me out... Thanks in advance.
Pradeep
February 9, 2007 at 7:29 am
to run a vbs file dont you need xp_cmdshell 'wscript.exe c:\Name.vbs' as the command?
Lowell
February 9, 2007 at 7:33 am
Thanks for ur reply Lowell. I tried the command which you specified. Still i am getting the same output 'NULL' and the file is not getting executed. Please look into this.
February 9, 2007 at 7:56 am
you are right...i get the same results...it runs to completion and returns null.
what are you expecting to get back, though? you don't expect it to return the html as results right, just zero or some number if it failed to run successfully?
Lowell
February 9, 2007 at 7:58 am
For me, the following works - EXECUTE master.dbo.xp_cmdShell 'cscript.exe \\asm8\c$\transf~1\transfer.vbs'
I use cscript.
~Steve
February 9, 2007 at 8:04 am
In fact I want to open an ASP page. yahoo.com is an example. Steve, did you use the same script which I had entered? When I use cscript to run the vbs file, I get the following result:
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
NULL
NULL
Please help me out with this...
February 9, 2007 at 8:17 am
Pradeep,
I don't think that you can make a web page open using this method. My understanding is that only batch-type commands will run, not something visual or requiring user input.
~Steve
February 9, 2007 at 8:20 am
Maybe something like the following will work:
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run("""c:\program files\internet explorer\iexplore.exe"" http://www.yahoo.com")
February 9, 2007 at 8:35 am
To the best of my knowledge SQL Server is non interactive. Which means that u can't invoke a new program from it. I have tried to invoke a exe from SQL and found that the exe was invoked properly but the application was not called and when i checked the same in the process list i found that the exe was invoked and SQL server was not able to open that in a new windows or as a interactive application.
Any comments on this is really welcome as this will solve a problem that even i am facing.
Thanks in advance.
Cheers,
Sugeshkumar Rajendran
SQL Server MVP
http://sugeshkr.blogspot.com
February 9, 2007 at 9:58 am
ok, I see the issue is that you need an inet control to read a web page....no problem...so i built a dll in vb6 with just one public method.
a .vbs file with these commands in it returns a msgbox with the text from any web page passed to it...
so how do i get it to SQL server? write a file and bcp it in? any ideas?
as soon as i know how to get it into sql server, add add the same thing for an FTP file and give everyone the source code...it's really like 6 lines of code...very simple.
Set x = WScript.CreateObject("WebReader.Reader")
msgbox x.GetWebPageContentsAsString("http://www.yahoo.com")
Lowell
Viewing 10 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic. Login to reply