Jump to content

Launch BAT File with Parameters


mboucher

Recommended Posts

 

Actually, you might should use shell_exec.

 

Don't think I'm understanding it correctly...

<?php
$output= shell_exec('test.bat');
echo $output;
?>

 

Should execute test.bat, which simply creates a new folder.  But when I open the page, no folder is created.

Yeah, its top of my head coding.

I missed a end quote

<?php
echo getcwd() . '/test.bat does ' . (is_file('test.bat')?'':''not ') . 'exist.';
?>

 

if it exists, than ya may want to check safe mode in php.ini and disable it or create an executable dir so php can run external apps

 

 

Yeah, its top of my head coding.

I missed a end quote

<?php
echo getcwd() . '/test.bat does ' . (is_file('test.bat')?'':''not ') . 'exist.';
?>

 

if it exists, than ya may want to check safe mode in php.ini and disable it or create an executable dir so php can run external apps

 

Thanks, but still getting a parse error

I've got it to work with..

<?php
echo exec('cmd /c test.bat');
?>

 

But...

I am unable to pass parameters to it.  If I hard code them in, it works fine, but I am trying to submit them from a form, and it loads filename.php?Parameter1=a&Parameter2=b

 

So my code is:

<?php
echo exec('cmd /c test.bat $Parameter1 $Parameter2');
?>

 

But this doesn't seem to work?

 

 

Or you could just do what ever the batch file does in PHP.

 

 

As far as I know, there isn't anything a batch file does that PHP can't.

 

 

By the way, the cmd /c probably wouldn't be needed with shell_exec().

 

 

Anyway, it looks like your code is relying on register_globals, and that setting is just straight up evil when set to on.  Find a tutorial on $_GET.

 

Short explanation:

 

somepage.php?foo=bar

 

$_GET['foo'] would be "bar"

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.