MSFN Forum: VBS to change comp name - MSFN Forum

Jump to content


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

VBS to change comp name Win7 Like Rate Topic: -----

#1 User is offline   LeppeRMessiaH 

  • Newbie
  • Group: Members
  • Posts: 19
  • Joined: 01-May 08
  • OS:XP Pro x86
  • Country: Country Flag

Posted 08 April 2011 - 06:51 AM

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

Posted Image

This post has been edited by LeppeRMessiaH: 08 April 2011 - 06:53 AM



#2 User is offline   Tripredacus 

  • K-Mart-ian Legend
  • Group: Super Moderator
  • Posts: 8,665
  • Joined: 28-April 06
  • OS:Server 2012
  • Country: Country Flag

Posted 08 April 2011 - 07:49 AM

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.

#3 User is offline   gunsmokingman 

  • MSFN Master
  • Group: Super Moderator
  • Posts: 2,351
  • Joined: 02-August 03
  • OS:none specified
  • Country: Country Flag

Posted 08 April 2011 - 10:51 AM

Another way, this would require that a user is log on.
Dim Act :Set Act = CreateObject("Wscript.Shell")
Dim UNm :UNm = Act.ExpandEnvironmentStrings("%UserName%")



#4 User is offline   LeppeRMessiaH 

  • Newbie
  • Group: Members
  • Posts: 19
  • Joined: 01-May 08
  • OS:XP Pro x86
  • Country: Country Flag

Posted 08 April 2011 - 01:01 PM

Thanks for answering, I think I got it

#5 User is offline   Yens 

  • Group: Members
  • Posts: 2
  • Joined: 15-March 12
  • OS:Windows 7 x86
  • Country: Country Flag

Posted 15 March 2012 - 08:30 AM

Can you please share your .vbs script

#6 User is offline   LeppeRMessiaH 

  • Newbie
  • Group: Members
  • Posts: 19
  • Joined: 01-May 08
  • OS:XP Pro x86
  • Country: Country Flag

Posted 15 March 2012 - 08:34 AM

There

Attached File(s)



Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2013 msfn.org
Privacy Policy