简体   繁体   中英

Passing string(a paragraph) using command line argument to powershell script in php

I'm executing Shell_Exec() using php in the following way:

$com='C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe  -ExecutionPolicy Bypass -NoProfile -InputFormat none -command ".\"'.$pshell_path.'"" "'.$name.'" "'.$pbody.'" < NUL';
$Result = Shell_Exec ($com);

where $pshell_path is path to powershell script, $name contains names and $pbody is declared as follows:

$pbody = "Ignore this mail. This is a test mail. Multiline text mail. Hello world"

which is some paragraph of text. When I execute Shell_Exec() $pbody variable will have only first word Ignore and not the whole paragraph. How to correct this?

<?php
$pbody = "Ignore this mail. This is a test mail. Multiline text mail. Hello world";

$pshell_path = '/root';
$name = 'Username';
  
$com="C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe  -ExecutionPolicy Bypass -NoProfile -InputFormat none -command .\\$pshell_path $name '$pbody' < NUL";

echo 'My Command line is: '. $com;

$result = Shell_Exec ($com);

?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM