LeppeRMessiaH Posted April 8, 2011 Posted April 8, 2011 (edited) 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, 2011 by LeppeRMessiaH
Tripredacus Posted April 8, 2011 Posted April 8, 2011 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.
gunsmokingman Posted April 8, 2011 Posted April 8, 2011 Another way, this would require that a user is log on.Dim Act :Set Act = CreateObject("Wscript.Shell")Dim UNm :UNm = Act.ExpandEnvironmentStrings("%UserName%")
LeppeRMessiaH Posted April 8, 2011 Author Posted April 8, 2011 Thanks for answering, I think I got it
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now