简体   繁体   中英

Get current logged on Windows 7 user, PHP

The command that I want to use is: "wmic /node:(computer name) computersystem get username"

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. However, I need help. I know some PHP, but some pointers or suggestions on how to start would be helpful.

Any suggestions are welcome. Please and thank you.

Simply use system() This function executes a system command and gives you the result back.

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

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

In your case :

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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