[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Call an ASP file from an vb EXE

Posted on 2004-10-22
9
Medium Priority
?
232 Views
Last Modified: 2010-05-02
I want to make an .EXE file that I can shadule to run daily.
When this file gets executed I want it to run/call an .ASP page.
How can I do this?
Thanks
0
Comment
Question by:AutomaticSlim
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 3
9 Comments
 
LVL 32

Expert Comment

by:Erick37
ID: 12382835
Add a reference to "Microsoft Internet Controls" from the Project->References menu.
Place a Webbrowser control on your form.

Sub Form_Load()

Show
Doevents
Webbrowser1.Navigate2 "http://www.url.com/file.asp"

end Sub
0
 
LVL 53

Expert Comment

by:Ryan Chong
ID: 12383307
try use URLDownloadToFile API, like:

Try use the URLDownloadToFile API

Example:

Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long

Public Function DownloadFile(URL As String, LocalFilename As String) As Boolean
    Dim lngRetVal As Long
    lngRetVal = URLDownloadToFile(0, URL, LocalFilename, 0, 0)
    If lngRetVal = 0 Then DownloadFile = True
End Function

Private Sub Form_Load()
    Randomize
    rndkey = Int(Rnd * 100000")
    URL = "http://www.abc.com/pass_management/user_auth.php?name=USERNAME&pass=PASSWORD" & "&rndkey=" & rndkey
    DownloadFile URL , "c:\test.txt"
End Sub

also:

Ensuring URLDownloadToFile Bypasses a Cached File Copy
http://vbnet.mvps.org/code/internet/urldownloadtofilenocache.htm

FYI, by download a file by url is same as run/call that page.
0
 

Author Comment

by:AutomaticSlim
ID: 12383576
I have vb 6.0  Do I need .Net for any of the above? I coulden't get any of the examples to work.
Is there any more detail steps that I need to know?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:AutomaticSlim
ID: 12383606
Do I need to have the code in a Module or Form if I want the program to be an exe?
0
 
LVL 53

Expert Comment

by:Ryan Chong
ID: 12383845
For .Net version (VB.NET), try:

'Get Web Page Content
    Public Function getURLDownload(ByVal URL As String) As String
        Dim tmp As String

        Dim req As System.Net.WebRequest = System.Net.WebRequest.Create(URL)

        Try
            Dim result As System.Net.WebResponse = req.GetResponse()
            Dim ReceiveStream As System.IO.Stream = result.GetResponseStream()

            Dim read() As Byte = New Byte(512) {}
            Dim bytes As Integer = ReceiveStream.Read(read, 0, 512)

            While (bytes > 0)
                Dim encode As System.text.Encoding = System.Text.Encoding.GetEncoding("utf-8")
                tmp = tmp & encode.GetString(read, 0, bytes)
                bytes = ReceiveStream.Read(read, 0, 512)
            End While

            Return tmp
        Catch Exc As Exception
            Return ""
        End Try
    End Function
0
 

Author Comment

by:AutomaticSlim
ID: 12384001
Ok This is what I did:

Ctrl + T  and then I added "Microsoft Internet Controls" .
Next I added this to my Form
then I inserted this code:

Private Sub Main()
    WebBrowser1.Navigate2 "http://www.something.com/test.asp"   
End Sub

When I run this the Form opens and loads the page and runs the asp.
But now the form stays open on the screen, I want to close everything after it is ran the asp.
0
 
LVL 32

Accepted Solution

by:
Erick37 earned 260 total points
ID: 12384084
Try this...

WebBrowser1.Navigate2 "http://www.microsoft.com"

'Wait here until document loads
Do While WebBrowser1.ReadyState <> READYSTATE_COMPLETE
    DoEvents
Loop

'Unload the form and the program ends
Unload Me
0
 
LVL 32

Expert Comment

by:Erick37
ID: 12384365
If you do not need a user interface, then add the following code to a Module.  It creates an instance of InternetExplorer and navigates to the specified page.  Then quits.  No references or controls needed.

Option Explicit

Sub main()
    Dim ie As Object
    Set ie = CreateObject("InternetExplorer.Application")
    ie.Navigate "http://msdn.microsoft.com"
    Do While ie.ReadyState <> READYSTATE_COMPLETE
        DoEvents
    Loop
    Debug.Print ie.StatusText
    Debug.Print ie.LocationName
    Debug.Print ie.LocationURL
    ie.Quit
    Set ie = Nothing
End Sub

0
 
LVL 53

Expert Comment

by:Ryan Chong
ID: 12388082
Find a better way maybe, that's using M$ Internet Transfer Control ActiveX (you can select it from Components), where it got a method called openURL which do exact the same above to retrive data from an URL.

Example:

Inet1.OpenURL url

cheers
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question