首页 > 解决方案 > 使用 php exec() 调用该批处理文件时,批处理文件重定向到一个空文件

问题描述

我有一个 Windows 批处理文件gcloud_batch.bat

gcloud auth application-default print-access-token > token.txt

和 php 文件:

exec("gcloud_batch.bat", $output, $return);

当我从浏览器运行 php 文件时,它创建token.txt但为空。但是当我从命令行运行批处理文件时它工作得很好。

我错过了什么?

标签: phpbatch-file

解决方案


推荐阅读