469,287 Members | 2,442 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,287 developers. It's quick & easy.

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
Jul 31 '08 #1
12 3605
DrBunchman
979 Expert 512MB
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
Jul 31 '08 #2
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:

Expand|Select|Wrap|Line Numbers
  1. dim oShell
  2. set oShell = CreateObject("WScript.Shell") 
  3. oShell.run"print" 
  4. 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
Jul 31 '08 #3
DrBunchman
979 Expert 512MB
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.
Expand|Select|Wrap|Line Numbers
  1. 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.
Jul 31 '08 #4
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.CreateObject("Wscript.Shell")
objScriptShell.Run "C:\Inetpub\wwwroot\WebAdmin\Rewards\print.exe ", 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 "application", 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
Jul 31 '08 #5
DrBunchman
979 Expert 512MB
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
Aug 1 '08 #6
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
Aug 1 '08 #7
DrBunchman
979 Expert 512MB
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
Aug 5 '08 #8
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
Aug 6 '08 #9
DrBunchman
979 Expert 512MB
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
Aug 6 '08 #10
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
Aug 6 '08 #11
jeffstl
432 Expert 256MB
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
Aug 6 '08 #12
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
Aug 11 '08 #13

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

23 posts views Thread by Fabian Müller | last post: by
35 posts views Thread by hasho | last post: by
13 posts views Thread by mitchellpal | last post: by
3 posts views Thread by cberthu | last post: by
9 posts views Thread by CryptiqueGuy | last post: by
12 posts views Thread by Rahul | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.