在Windows 8.1中通过exec()执行具有管理员权限的批处理脚本 [英] Execute batch script with admin rights in windows 8.1 by exec()

查看:287
本文介绍了在Windows 8.1中通过exec()执行具有管理员权限的批处理脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用exec()从php运行一个批处理文件,但是它不起作用。当我在管理员模式下的命令窗口中运行相同的脚本时,该脚本可以工作。

I am trying to run a batch file from php with exec() but it is not working. When I run the same script in a command window in admin mode the script works.

现在,我想知道如何在php中配置可以执行我的脚本。 ADMIN模式。

Now I want to know how can I configure in php that my script can be execute with ADMIN mode.

推荐答案

您可以使用 RunAs命令。因为它将询问管理员密码,并且您正在从Web运行它,所以应该将管理员密码传递给命令。

You can use RunAs Command. Since it will ask admin password and you are running it from web you should pipe the admin password to the command.

exec('echo adminpassword | runas /user:administrator fullPathToProgram',$output);
print_r($output);

这篇关于在Windows 8.1中通过exec()执行具有管理员权限的批处理脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆