就這樣…
[root@h710-ha1 ~]# name=`whoami`
[root@h710-ha1 ~]# echo $name
root
or
[root@h710-ha1 ~]# name=$(whoami)
[root@h710-ha1 ~]# echo $name
root
windows
D:\xampp\htdocs\project_test>set test=%USERDOMAIN%\%USERNAME%
D:\xampp\htdocs\project_test>echo %test%