Click here to Skip to main content
15,920,596 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am new in php. i am creating a batch file for open vlc application. Now i want to link this batch file to button. So after click on button the vlc application is run.

What I have tried:

L am creating a batch file and i html crate the function runbat() in this function i am giving a path of vlc. And in Html in onclick m giving this function.
Posted
Updated 19-Jul-18 23:08pm
Comments
Mohibur Rashid 20-Jul-18 1:08am    
you want to run vlc application on click?
Richard MacCutchan 20-Jul-18 3:50am    
Where is the batch file stored and what is it trying to do?

1 solution

Thre are multiple solutions to execute PHP code upon a button click. I think this SO thread covers them all:
Execute PHP function with onClick - Stack Overflow[^]

To execute a batch file use the PHP: exec - Manual[^] function. It will start cmd.exe which must be specified when using other functions like system():
PHP
// Using exec() which starts cmd.exe
exec($path_to_batch_file);
// Using system which requires specifying cmd.exe for batch files
system("cmd /c $path_to_batch_file");

Note that PHP code is executed on the server and you can therefore only execute batch files on the server. There is no method to initiate executing batch files on a client by a web page.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900