你能在vbs中获得pc用户名吗? [英] can you get the pc user name in vbs?

查看:29
本文介绍了你能在vbs中获得pc用户名吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在visual basic (C:\User\"here") 中找到PC 用户.得到之后,直接保存为字符串即可.

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 cannot find out how to do this

推荐答案

相当简单,从这里 ( http://blogs.msdn.com/b/alejacma/archive/2008/03/11/how-to-get-the-user-running-a-vbscript.aspx )

Fairly simple, from here ( http://blogs.msdn.com/b/alejacma/archive/2008/03/11/how-to-get-the-user-running-a-vbscript.aspx )

Dim networkInfo
Set networkInfo = CreateObject("WScript.NetWork") 

Dim infoStr
infoStr = "User name is     " & networkInfo.UserName & vbCRLF & _
          "Computer name is " & networkInfo.ComputerName & vbCRLF & _
          "Domain Name is   " & networkInfo.UserDomain

MsgBox infoStr

这篇关于你能在vbs中获得pc用户名吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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