How to open .exe file in php and not running in the backgrou

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
munhing
Forum Newbie
Posts: 2
Joined: Fri Aug 26, 2005 10:40 pm

How to open .exe file in php and not running in the backgrou

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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?
User avatar
Trenchant
Forum Contributor
Posts: 291
Joined: Mon Nov 29, 2004 6:04 pm
Location: Web Dummy IS

Post 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).
munhing
Forum Newbie
Posts: 2
Joined: Fri Aug 26, 2005 10:40 pm

Post 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?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
Post Reply