Make asp-script server automatically start every day

Is it possible to create a batch file that opens firefox, starts a website and closes firefox again?

Sort of:

@echo off
start firefox http://.....

That's where I am stuck ... It should close firefix again when the site finishes loading.

It is used to run a maintenance script every night at 23:59. The script is based locally, but you cannot use an asp file without using a server, so I posted it as a website.

+3
source share
2 answers

Adapted from an article I wrote on aspfaq.com a few years ago.

AT- Windows Scripting Host ( ) VBS .

ASP VBS. (1) VBS; (2) Server.CreateObject CreateObject; (3) <%%> , (, response.write HTML-). , YMMV.

VBS AT ( Windows). AT , , . AT/? .

, 9:00 , ( ):     

at /delete /y 
at 9:00 /every:m,t,w,th,f d:\net\shared\getdata.vbs      

, - ; . , " " ​​ " reset " ( , , , ), .

WSH, CDONTS . KB # 221495.

, , SQL Server, . , , ASP-, , ASP-.

+6

-, .

Option Explicit
On Error Resume Next

' Declare our vars
Dim objWinHttp, strURL

' Request URL from 1st Command Line Argument.  This is
' a nice option so you can use the same file to
' schedule any number of differnet scripts just by
' changing the command line parameter.
'strURL = WScript.Arguments(0)

' Could also hard code if you want:
strURL = "http://www.example.com/myscript.asp"

' For more WinHTTP v5.0 info, including where to get
' the component, see our HTTP sample:
' http://www.asp101.com/samples/winhttp5.asp
Set objWinHttp = CreateObject("WinHttp.WinHttpRequest.5")
objWinHttp.Open "GET", strURL
objWinHttp.Send

' Get the Status and compare it to the expected 200
' which is the code for a successful HTTP request:
' http://www.asp101.com/resources/httpcodes.asp
If objWinHttp.Status <> 200 Then
    ' If it not 200 we throw an error... we'll
    ' check for it and others later.
    Err.Raise 1, "HttpRequester", "Invalid HTTP Response Code"
End If

' Since in this example I could really care less about
' what returned, I never even check it, but in
' general checking for some expected text or some sort
' of status result from the ASP script would be a good
' idea.  Use objWinHttp.ResponseText

Set objWinHttp = Nothing

If Err.Number <> 0 Then
    ' Something has gone wrong... do whatever is
    ' appropriate for your given situation... I'm
    ' emailing someone:
    Dim objMessage
    Set objMessage = Server.CreateObject("CDO.Message")
    objMessage.To       = "you@example.com"
    objMessage.From     = "cron job <cron@example.com>"
    objMessage.Subject  = "An Error Has Occurred in a " _
        & "Scheduled Task"
    objMessage.TextBody = "Error #: " & Err.Number & vbCrLf _
        & "From: " & Err.Source & vbCrLf _
        & "Desc: " & Err.Description & vbCrLf _
        & "Time: " & Now()

    objMessage.Send
    Set objMessage = Nothing
End If

strURL script, strURL = WScript.Arguments(0) URL- . cscript.exe.

ASP, , script IP- , , .

: .

+3

All Articles