can you get the pc user name in vbs?

前端 未结 2 1725
耶瑟儿~
耶瑟儿~ 2020-12-12 07:21

Is there way to find the PC user in visual basic (C:\\User\\\"here\"). After we get it, just save it as a string.

I know the answer might be a bit obvious, but I ca

2条回答
  •  轮回少年
    2020-12-12 08:06

    The simplest way might be to query the environment.

    There are USERDOMAIN, USERNAME, USERPROFILE and COMPUTERNAME environment variables containing the obvious values.

    Querying those would depend solely on WScript.Shell instead of on WScript.Network as in the accepted (and correct) answer. If you already have a reference to the shell, this might be a slightly more comfortable way.

提交回复
热议问题