在windows中使用COM执行php命令
我尝试在php中执行此操作:在windows中使用COM执行php命令,php,windows,Php,Windows,我尝试在php中执行此操作: $cmd = 'ffmpeg.exe -rtbufsize 1500M -f dshow -i video="Microsoft® LifeCam Studio(TM)" full-video.webm'; $shell = new \COM("WScript.Shell"); $shell->Run($cmd, 0, false); 如果我在命令行(cmd)中运行该命令,它会工作,但从php运行的命令不工作。如果我尝试回显该命令,结果是: ffmpeg.
$cmd = 'ffmpeg.exe -rtbufsize 1500M -f dshow -i video="Microsoft® LifeCam Studio(TM)" full-video.webm';
$shell = new \COM("WScript.Shell");
$shell->Run($cmd, 0, false);
如果我在命令行(cmd)中运行该命令,它会工作,但从php运行的命令不工作。如果我尝试回显该命令,结果是:
ffmpeg.exe -rtbufsize 1500M -f dshow -i video="Microsoft® LifeCam Studio(TM)" full-video.webm
我想是关于字符串重排的,但我不知道。听起来您实际上想在这里使用exec:
输出的不同之处在于,您输入的是utf-8字符,而不是告诉浏览器您希望在输出时将其解释为utf-8。我需要使用此命令使shell理解utf-8
chcp 65001
要使其永久化,我需要执行以下操作:
HKEY\U LOCAL\U MACHINE\Software\Microsoft\Command]
处理器\自动运行
]chcp 65001
我不使用浏览器。。是命令行。(cmd)。我不使用exec,因为exec正在阻止进程。(在linux中我可以使用>/dev/null 2>&1&但在windows中我不知道)。我在windows 7中尝试了这一点,但不起作用(在windows 8中完全起作用)
$shell = new \COM("WScript.Shell");
$shell->Run(utf8_decode($cmd), 0, false);