Call VB exe from ASP

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gray d newbie
    New Member
    • Jul 2008
    • 13

    Call VB exe from ASP

    Greetings All,

    I have an execution file called print.exe developed by using VB6, it has some printing function in the page load. I have an ASP page that has a "Print" button which will launch this exe when click. May I know how am I supposed to go about this? Or is it anyway I could incorporate the exe (with a button to perform the printing) inside the ASP page so that the end user can click on the VB "Print" button to print?

    Thank you very much.

    Best Regards
    Gray d Newbie
  • DrBunchman
    Recognized Expert Contributor
    • Jan 2008
    • 979

    #2
    Hi gray,

    Use a shell command to run an exe on the server. Check out these and let me know how you get on.

    Hope this helps,

    Dr B

    Comment

    • gray d newbie
      New Member
      • Jul 2008
      • 13

      #3
      Hi Dr B,

      Thank you so much for your guide. I tried some of the code but it doesn't work as planned. Perhaps the structure of the code is not correct. Can you please check for me and identified my error? My code is something like this:

      Code:
      dim oShell
      set oShell = CreateObject("WScript.Shell") 
      oShell.run"print" 
      WScript.Sleep 2500
      but the page returns error says that the WScript is undefined. How am I supposed to defined it?? Or do I missed out anything?

      Thank you very much.

      Best Regards,
      Gray d' Newbie
      Last edited by DrBunchman; Jul 31 '08, 08:10 AM. Reason: Added [Code] Tags - Please use the '#' button

      Comment

      • DrBunchman
        Recognized Expert Contributor
        • Jan 2008
        • 979

        #4
        By the way Gray, welcome to Bytes.com! I hope you find the site useful.

        You need to put in the full path of the exe you are trying to run. e.g.
        Code:
        oShell.run "C:\program files\vb6\print.exe"
        Does that help?

        Dr B

        PS Please could you wrap all your code in [CODE] tags using the # button at the top of the editing window - it makes your posts much easier to read.

        Comment

        • gray d newbie
          New Member
          • Jul 2008
          • 13

          #5
          Thank you very much DrB. Yes. Full path does help. But I faced another problem now. Let me keep thing simple.

          I have an ASP page in the project folder located in the server, this page will call the exe and the exe will perform some print job based on the value grab from the ASP page. Below is my code in ASP:

          dim objScriptShell
          Set objScriptShell = Server.CreateOb ject("Wscript.S hell")
          objScriptShell. Run "C:\Inetpub\www root\WebAdmin\R ewards\print.ex e", 1, True

          When a client open up this ASP page, the exe will actually open up in the server, and it supposed to perform the printing, however when I check on the server task manager, the "print.exe" does appear in the "processes" but it is not in the "applicatio n", and it doesn't print out the intended result.

          My question is, am I making any mistake in the concept or flow, or anything else that preventing the exe run in a normal way?

          Thank you very much.

          Best Regards
          Gray d' Newbie

          Comment

          • DrBunchman
            Recognized Expert Contributor
            • Jan 2008
            • 979

            #6
            Does the exe require any user input or parameters to be passed to it? Does it pop-up a User Interface window on the server when it is called?

            Dr B

            Comment

            • gray d newbie
              New Member
              • Jul 2008
              • 13

              #7
              Thank you very much Dr B

              The EXE does not required to take in any parameter. And I don't UNLOAD the EXE interface because I want to test on whether does it call. All my codes are in FORM LOAD.

              Thank you so much for your time.

              Best Regards
              Gray d' Newbie

              Comment

              • DrBunchman
                Recognized Expert Contributor
                • Jan 2008
                • 979

                #8
                So do you think that the exe has failed to fire or that it is not behaving as expected once it's run?

                Dr B

                Comment

                • gray d newbie
                  New Member
                  • Jul 2008
                  • 13

                  #9
                  Greetings Dr.B

                  I think it is FIRED but not doing what it supposed to do.

                  Thank you very much

                  Best Regards
                  Gray d' Newbie

                  Comment

                  • DrBunchman
                    Recognized Expert Contributor
                    • Jan 2008
                    • 979

                    #10
                    I suspect it might be a permissions problem then.

                    Remember that the exe will be running as if the IIS user has started it not you so the IIS will require permissions to access any folders that the exe is using.

                    Dr B

                    Comment

                    • gray d newbie
                      New Member
                      • Jul 2008
                      • 13

                      #11
                      Thank you Dr.B but I already granted full control for everyone on the EXE and the folder that stores the documents which are going to be printed.

                      Thank you very much

                      Best Regards
                      Gray d' Newbie

                      Comment

                      • jeffstl
                        Recognized Expert Contributor
                        • Feb 2008
                        • 432

                        #12
                        Is this an ActiveX exe or a Standard exe? I believe you need the ActiveX exe control.

                        Also another thing you may have to try is asynchronous processing. This means that the exe must be fired, but immediately afterwards the session is released back to the asp.

                        Asynchronous Processing

                        I have used this method a few times to call a .exe processing program from a .dll which was called by a asp page.

                        So again, not sure if this is the final answer but its something you could try.

                        There is also a way to call the print dialog box with javascript. Not sure what your final goal is but you may not have to use a .exe if its acceptable to the requirements.

                        javascript print

                        Comment

                        • gray d newbie
                          New Member
                          • Jul 2008
                          • 13

                          #13
                          Thank you very much jeffstl,

                          I will look into that to see whether is it what I want. But I think what you said is correct. It should have been done in ActiveX, but I'm not sure how to do it at the mean time. I will look into some tutorial on that.

                          Thank you very much

                          Best Regards
                          Gray d' Newbie

                          Comment

                          Working...