Home  >  Article  >  Backend Development  >  php执行vbs脚本解决方法

php执行vbs脚本解决方法

WBOY
WBOYOriginal
2016-06-13 10:46:071919browse

php执行vbs脚本
vbs是打印excel文件,并执行打印操作。 使用cmd命令和直接运行vbs程序,都可进行打印。 而php调用vbs时,$returnvalue输出为0(代表执行成功),可就是不执行打印操作。 

PHP:

system("C:/print.vbs", $returnvalue);
echo $returnvalue;
?>

=====================
vbs :
templatePath="C:\2.xls"
'create object
Set oExcel=CreateObject("Excel.Application")
oExcel.DisplayAlerts = False
Set tmpExcel=oExcel.Workbooks.Open(templatePath,3,False)
oExcel.ActiveSheet.PageSetup.PrintGridLines = False 
oExcel.ActiveSheet.PrintOut
oExcel.ActiveWorkBook.Saved = False 
oExcel.Quit

------解决方案--------------------
你当人家都在 XP 下工作呀?

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn