April 8, 201115 yr Now I'm using a .vbs that changes the comp name to a fixed one inside the script. However, I was wondering if it is possible to change the computer's name to one that includes the name of the current user. The best example for this is the OOBE of Windows 7 where it asks for user name then automatically sets the computer name like USERNAME-PC. Can vbs use variables like %USERNAME% or get that value from the registry and add something extra to the final result without asking for any input? Thanks Edited April 8, 201115 yr by LeppeRMessiaH
April 8, 201115 yr You can pull the currently logged in account from WMI, in the Win32_ComputerSystem you can get the UserName object. You'll need to do an LTrim on it because it will return COMPUTERNAME\USERNAME as part of the data.
April 8, 201115 yr Another way, this would require that a user is log on.Dim Act :Set Act = CreateObject("Wscript.Shell")Dim UNm :UNm = Act.ExpandEnvironmentStrings("%UserName%")
Create an account or sign in to comment