By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,296 Members | 1,446 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,296 IT Pros & Developers. It's quick & easy.

how to invoke a bat file from php by passing parameters on windows

P: 29
hello everyone..... i am ajay and i am new to php. in my project i have an option to invoke a bat file by passing parrameters and to diplay the result.

i tried this code but my page got hung or display nothing...

exec("c:\collabland\collabland.bat $distcode $tlkcode $villacod $block $svno");

here by passing this parameters to collabland.bat, a sketch will be generated based on the parameters and it should be displayed. when i type in command promt it is working. but not in php. i want to pass the parameters to bat file and based on the values generate the sketch and display it in my php project. i am using windows xp. i am passing the values in button click.

please suggest a solution .

thanks for spending your valuable time.
Jan 31 '08 #1
Share this Question
Share on Google+
3 Replies


harshmaul
Expert 100+
P: 490
Hi Ajay,
Quick question to help me diagnose better,
Is the bat file on the client machine or the server?

I'm only asking to make sure your not tring to run a bat file thats on the client from the server, as that isn't possible.
Jan 31 '08 #2

P: 29
Hi Ajay,
Quick question to help me diagnose better,
Is the bat file on the client machine or the server?

I'm only asking to make sure your not tring to run a bat file thats on the client from the server, as that isn't possible.
hi harsh....

my bat file is on the client side.....ie my bat file is on the c: folder and i am using dreamweaver for my php coding and my php is also saved in c: folder.
Feb 1 '08 #3

harshmaul
Expert 100+
P: 490
Hi,
This is one way to do it....


Expand|Select|Wrap|Line Numbers
  1. <?php
  2. header("Content-type: application/bat ");
  3. header("Content-Disposition: attachment; filename=mybat.bat");
  4. ?> 
  5. dir/s
and obviously change the dir/s to the batch commands.

You can't directly open files on a client from a server.
Feb 1 '08 #4

Post your reply

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