简体   繁体   English

获取当前登录的Windows 7用户PHP

[英]Get current logged on Windows 7 user, PHP

The command that I want to use is: "wmic /node:(computer name) computersystem get username" 我要使用的命令是:“ wmic / node :(计算机名)computersystem获取用户名”

This command simply returns the current user that is logged on. 此命令仅返回当前登录的用户。 I want this embedded into our intranet (PHP), so that users can know if a particular computer is in use. 我希望将其嵌入到我们的Intranet(PHP)中,以便用户可以知道是否正在使用特定计算机。 However, I need help. 但是,我需要帮助。 I know some PHP, but some pointers or suggestions on how to start would be helpful. 我知道一些PHP,但是一些有关如何启动的指针或建议会有所帮助。

Any suggestions are welcome. 欢迎任何建议。 Please and thank you. 谢谢,麻烦您了。

Simply use system() This function executes a system command and gives you the result back. 只需使用system()该函数即可执行系统命令并返回结果。

string system( string $command [, int &$return_var ])

http://php.net/manual/en/function.system.php http://php.net/manual/en/function.system.php

In your case : 在您的情况下:

<?php
    echo "<pre>".system("wmic /node:(computer name) computersystem get username")."</pre>";
?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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