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
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.
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