Page 1 of 1
How to open .exe file in php and not running in the backgrou
Posted: Fri Aug 26, 2005 11:04 pm
by munhing
Hi...
I'm currently programming a cash register system in php. I'm having difficulty in executing a .exe file which i have created using VB6 to open the cash drawer.
However, when i execute it using the exec('c:\creg.exe'), it will not open the drawer. When i check the Windows Task Manager, i can see that the program is running by the IUSR_XXXXX but it does not open the cash drawer... it seem like it is running in the background.
I assure you that the .exe program works fine when i execute it directly by double clicking it. But thru php, it won't work.
Anyone can help?
Thanks,
munhing
Posted: Fri Aug 26, 2005 11:13 pm
by feyd
typically, you don't open an .exe in php, unless it's to send it to the user. I'm going to guess this is being used through an ActiveX, in which case, it's already loaded on the user's machine. Merely running an .exe from php will only interact with the server itself, not affecting anything on a client (most often). Maybe more explaination is in order?
Posted: Fri Aug 26, 2005 11:31 pm
by Trenchant
feyd wrote:typically, you don't open an .exe in php, unless it's to send it to the user. I'm going to guess this is being used through an ActiveX, in which case, it's already loaded on the user's machine. Merely running an .exe from php will only interact with the server itself, not affecting anything on a client (most often). Maybe more explaination is in order?
In the setup that I'm guessing he is using there would be no Client. The Client and Host are the same computer. Basically loading a page via Localhost. As far as connecting to an exe file goes I'm not sure. I know there is a way to send commands to an exe file but I'm not sure how to do it.
It might be easyer to recreate your VB6 file into a plain C command prompt. Even better yet you may be able to open the cash register from CMD(depending on your your shop's computer is setup).
Posted: Sat Aug 27, 2005 12:06 am
by munhing
Thanks for the replies.
Basically i'm running all this locally in my localhost...
I've also created another program in VB6 called open.exe. This program will execute the creg.exe.
VB code for this is
Private Sub Form_Load()
Shell "c:\creg.exe"
End
End Sub
Then in php, i code this:
<? exec('c:\open.exe'); ?>
When i run it, it doesn't work. Still in the Windows Task Manager, i can see that the program is running by the IUSR_XXXXX but it does not open the cash drawer... it still runs in the background
I'm desperate to find a solution for this... There is no error displayed as i run the php script.
Any other solutions?
Posted: Sat Aug 27, 2005 12:16 am
by feyd
you'll either have to switch user credentials in the exe, or set php to be interactive with the desktop. Even then, it may not work.