locked
open a web page through SQL SQL job RRS feed

  • Question

  • User-1704425100 posted

    Hi all,

     now, i create a job to open a page on timely basis. The job's Vb script is like that:

    Dim WshShell
    Set WshShell =CreateObject("WScript.Shell")
    WshShell.Run ("http://www.google.com")
    Set WsShell = Nothing

     
    when i run that job, i got that error:

    The job succeeded.  The Job was invoked by User host\username.  The last step to run was step 1 (Step 1).

     
    how can i solve it? i still don't know whether that script will open a webpage or not

     

    Monday, September 11, 2006 11:25 PM

All replies

  • User1439985827 posted

    The following script opens a webpage in a VBS Script:

    Dim WshShell
    Set WshShell = CreateObject("WScript.Shell")
    WshShell.Run "iexplore.exe http://www.google.com"
    Set WsShell = Nothing

    Tuesday, September 12, 2006 1:53 AM
  • User-1704425100 posted

    I think that one will work in web page. But, now i m trying in SQL job. I have tried with that code. But, nothing happen.

     regards,
     

    Tuesday, September 12, 2006 2:03 AM
  • User1224304770 posted
    It seems to be impossible to open a website through SQL Server, neither using SQL Agent Job (ActiveX script task), nor using xp_cmdshell. I tried both, and the IEXPLORER process can be started (you can check in Task Manager) and then hung, waiting for some response. I guess this is because xp_cmdshell operates synchronously. Control is not returned until the command shell command completes. And the SQL Server can't proceed with reponse from IEXPLORER process so both IEXPLORER and SQL Server hangs.
    Wednesday, September 13, 2006 2:24 AM
  • User-1704425100 posted
    so, how abt calling a bat file. And then, through bat file, call the web page. is it the possible way?
    Wednesday, September 13, 2006 2:32 AM
  • User-1913149414 posted

     It can be done but you have to do some tricks :

    I created a sql job and included one step, this is an cmdexec step using this command:

    "C:\Program Files\Internet Explorer\iexplore.exe" "http://localhost/webpage.aspx?ACTION=DOSOMETHING"

     in my code I act upon this action parameter by starting a proces (code is from the page_load function in my webpage): 

                        ProcessJob(action);
                        string jsOpenWindow = "<script language='javascript'>" +
                            "window.opener = 'x';" +
                            "window.close();" +
                            "</script>";
                        Page.RegisterStartupScript("_OpenPage", jsOpenWindow);       

    The second part is important : by setting the window opener to 'x' no question is asked when closing this webpage, window.close automatically closes the browser window. 

     This solves the endless running job. Using explorer as the host won't kill the job, iexplorer does kill the job. I need a full path to ieplorer because no path is set to iexplorer on the sql server I think.

     Regards,

    Wim

    Tuesday, September 23, 2008 7:53 AM
  • User901183018 posted

    In our team we are using hta files.

    the SQL job command is as follows:

    c:\windows\system32\mshta.exe "L:\SQLJobs\batch_emails.hta"

    And the hta file content is:

    <HTML>
    
    <HEAD>
    </HEAD>
    
    <FRAMESET ROWS="100%">
    	<FRAME NAME="doit" SRC="http://localhost/HWE-PCN/Automation/Index" onload="window.close();">
    </FRAMESET>
    
    </HTML>
    
    
    This opens a session of IE and the js code closes the session automatically.

     

    Tuesday, November 9, 2010 5:45 AM