Page 1 of 1

Calling MS-Windows associated file to run the Windows progra

Posted: Fri Aug 05, 2016 2:20 pm
by bowlesj
Hi, I am trying to (either with Javascript or with PHP or both for that matter) (while running under XAMPP) call/open a file which is associated with a Windows program such that the windows program is called to read/process the file. In my case the windows program is "Band In A Box" and the file can be any file that "Band In A Box" typically runs. Does anyone know where I can get some examples of how to do this.

To give you an idea of what I am hoping for, In MS-Access the command is shown below ("Me.fldS_BIAB_File" contains the file name).
Application.FollowHyperlink "C:\Access\BIAB\" & Me.fldS_BIAB_File, , True
or
'MyAppID = Shell("C:\Program Files (x86)\Microsoft Office\Office12\Excel.exe C:\Access\MyExcellFile", vbMaximizedFocus)

I tried this google search "opening a windows associated file with javascript" and 'opening a windows associated file with php" but they come back with opening php files.



Thanks,
John

Re: Calling MS-Windows associated file to run the Windows pr

Posted: Fri Aug 05, 2016 3:15 pm
by requinix
Javascript cannot do it at all. If you want to open a file on the server then PHP can do it. But I assume you want to open the file on the client?

It's not possible.

Re: Calling MS-Windows associated file to run the Windows pr

Posted: Fri Aug 05, 2016 3:26 pm
by bowlesj
I will be running the php code on my notebook computer using XAMPP. The "Band In A Box" file and the BIAB program will be on the notebook computer as well. So it sounds like it can be done. I was going to try the php fopen command but then I decided to do a google search "php shell command" and found this.
http://php.net/manual/en/function.shell-exec.php

Well I got the BIAB program to run with this command. Now all I have to do is figure out how to submit different files via a variable.

Re: Calling MS-Windows associated file to run the Windows pr

Posted: Fri Aug 05, 2016 5:13 pm
by bowlesj
I got the test to work. It seems to be just as fast as calling the file from MS-Access. I had to change the file separators to forward slashes to get it to work because the last backslash was escaping the single quote character. It looks better if they are all consistent.
$InputFile="BIAB_SONG_FILE.MGU";
$MyCommand='F:/bb/bbw.exe C:/BIAB_SongFiles/' . $InputFile;
$output = shell_exec($MyCommand);

Re: Calling MS-Windows associated file to run the Windows pr

Posted: Fri Aug 05, 2016 5:31 pm
by requinix
Yes, that's one of the ways to do it. shell_exec, exec, passthru, system, proc_* and p* functions... Some of those are more appropriate than others if you want to capture output or get detailed process information.

Most people have issues running programs at all - mostly about permissions - but if the backslashes were the only difficulty you had then that's great.