Get/Set ComputerName
by Corey A. Serrins, Kent Feid and Patrick Warme
These tasks have been deprecated as the tools are now built into the appliance when using the naming rule tasks. Will leave this page here for legacy purposes.
These tasks will work with both sysprepped images and scripted installs of XP/Vista/7/8/8.1/10
Major features include:
-using the K1 database
-using the K2 database
-using variable replacement
-using a data file
-dialog prompting
-and more...
There are 2 scripts included with this download, getcomputername and setcomputername, each has a 32 and 64 bit versions.
For complete instructions and commandline switches, please read the included README.txt file
Back to K2000 Deployment Workbench
Version History
=======================================================
v. 2.0.0.4 [12/14/19]
-Added switch to allow for user to override the 15 character limit, add the commandline switch '/no_netbios'
-Added switch to allow setcomputername to be run as a Windows postinstallation task, add the commandline switch '/in_windows"
v. 2.0.0.2 [07/22/19]
-Added file version to log
v. 2.0.0.1 [07/18/19]
-Chassis type 15 needs a formfactor assignment (ESMCS-392)
v. 2.0.0.0 [03/09/18]
- Properly identify Windows 10 (ESMCS-348)
- Changed how xml was modified from a search/replace to pure xml, which means that if doesn't exist, it will now be created (ESMCS-335)
- Moved log to \ProgramData\Quest\Scripting Ninjas
- Changed the way get/set read mac address and resolved a number of issues due to this (ESMCS-338)
- When model is VMWare, and $Serial model replacement, make serial number use characters from the right (ESMCS-339)
- Include looking at hostname for devices that were imported (ESMCS-340)
v. 1.5.5.2 [09/01/15]
-fixed an issue where [ ] ; characters weren't being stripped from the final computer name
-added Win10 to variable replacement
v. 1.5.5.1 [05/01/15]
-fixed issue where USB image deployments without network connection were failing
v. 1.5.0.1 [02/26/15]
-resolved an issue where the name in the unattend was not getting updated.
v. 1.5.0.0 [10/08/14]
-added /log to generate a log file for both get and set scripts.
-added variable replacement functionality to setcomputername
-added data file naming functionality to setcomputername
-added ability to use K1 database
-added ability to use K2 database
v. 1.3.0.0 [08/16/13]
-added /look: switch to getcomputername and setcomputername. If using this switch, it must be used in both applications.
-added /notrandom and /timeout: switch to setcomputername in case the name read was '*' (random) and that is undesired
v. 1.2.2.1 [10/02/12]
-modified an error to be more clear that the name file wasn't found or error with it.
v. 1.2.2.0 [08/03/12]
-added 15 character limit to the dialog box so user can't enter more than that.
-changed the default write drive letter to x:
v. 1.2.1.0 [08/01/12]
-added /drive to both get & set
v. 1.1.2.2 [05/20/12]
-changed dialog box so that timer was set, takes whatever name is is in box at that time.
v. 1.1.2.1 [05/04/12]
-fixed /timeout issue in getcomputername where it wasn't working at all.
-fixed issue where when timeout happened, computername was blank in getcomputername.
v. 1.1.2.0
-added in /debug
v. 1.1.1.2 [03/06/12]
-made maximum length of computer name 15 characters in get/set scripts, no exceptions.
v. 1.1.1.1 [12/22/11]
-removed guictrlread from nodialog, not sure why it was there, as we aren't reading gui
-was just looking for /dialog, changed it to read first 7 characters to match command line, like other options
-fixed bug where /dialog would not work unless the computer name was ""
v. 1.1.1 [11/21/11]
for SI, there is no name, so by default it will be "*" which will assign a random name
v. .65 [03/09/11]
switch was added to getcomputername.exe to allow for a timeout period on the dialog box to ask for a computer name.
Synatax for /timeout switch is /timeout:30 to timeout after 30 seconds. At this point, the unattend file would be left alone, assuming that the computername is set to "*" computer would end up with a random name.
/timeout at this time is meant to work with /dialog, if /timeout is used without /dialog, nothing will happen and there will be no affect on the outcome, but there will be no timeout.
v. .60 [02/28/11]
switch was added to getcomputername.exe to allow for naming the computer from commandline with /name:"name". This is more for one-offs.
switch was added to getcomputername.exe to allow the user to have a pop-up window to enter the computername. This is convenient for machines that come out of the box from the manufacturer, without any previous naming scheme for an organization.
v. .50 [02/23/11]
all known issues were resolved
all situations were tested with imaging and scripted install on Windows XP/Windows 7 and both architectures.
Corey - cserrins 10 years ago
Line:480
Error: Array variable has incorrect number of subscripts or subscript range exceeded. - JLadd 10 years ago
My VBS for "Applying the computername" midlevel task to copy the file from X to the local C is no longer working since the upgrade to 3.6 (one of many issues I've had with the upgrade to 3.6). - AJStevens 10 years ago
Make sure that the Apply computer name has 'cscript' before the name of the .vbs file. - cserrins 10 years ago
I'm guessing this wasn't present in 3.5 at this time, but it is now in 3.6 ? - AJStevens 10 years ago
I have this problem in WinPe3 when coming up with a plan to get the computer name and OU in which to join and delete the AD object if it already exists. I finagled around the problem by creating the MAC-address-file on X:\ myself (not pretty, but working) but would prefer to use the functionality provided by GetComputername.
SetComputername works like a charm btw. Thank you for that!
Cheers
Christian - ChristianT 10 years ago
Corey
Lead T3 Enterprise Solutions Consultant, K2000 - cserrins 10 years ago
Result: Error on initialization - tech@chch.org 10 years ago
When I have this as a midlevel task it fails. When I run it on a system that is working I get the Error on initialization. I verified all of the parameters are correct (k1 address, user and password, org name). Should I be able to run this from a booted up computer? - shanksr 10 years ago
How do I supply this to the script? The documentation is very terse on this point.
Thanks,
Erik - erikff 10 years ago
Thanks! - erikff 10 years ago
The files are AutoIT scripts that compile to be .exe files.
Corey - cserrins 9 years ago
It appears my deployment is stuck on the setcomputername... part but I don't know why.
Thanks. - jfrasier 9 years ago
Any ideas? Does something need to be in my unattend?
For reference the supplied Get/Set computername tasks from KBox work fine. My hope is that, given that all of our assets are already in K1000 and correctly named, I'd like to just use the SetComputerName so it doesn't matter if the machine's been renamed by some nefarious person. - pntaylor 8 years ago
-Corey - cserrins 8 years ago
Anyway, thank you for the response.
Edit: Made appropriate changes to unattend, worked a treat. Thanks again! - pntaylor 8 years ago
I use GetComputerName /dialog to enter a name of my choice, when SetComputerName runs later on, it seems to process ok, but the hostname does not get changed.
I ran SetComputerName /debug, and noticed that is parses OS version as W81, wondered if that might be an issue?
I'm using Windows 10 Enterprise Build 1511. - iainpeat 8 years ago
-Corey - cserrins 8 years ago
- yes
Also, do you have <ComputerName>*</ComputerName> in the unattend? That must be there for it to work.
- no! :)
Thanks for the tip! - iainpeat 8 years ago
Also, we're using the SetComputerName_x64.exe if that matters at all. - lucke 7 years ago
I am having a problem, where the computer name is not being set correctly for Windows 10 scripted deployments. It sets a generic name instead of the DELL service tag, which is what we use in our organization for naming our computers.
It gets and sets the computer name correctly during Windows 7 scripted installations.
The same GetComputerName.exe and SetComputerName.exe are used for both scripted installs.
Any assistance is appreciated thanks much. We are in the process of rolling out mass deployments - cplacide 8 years ago
but it looks, that wsname doesn´t work with windows 10. - aragorn.2003 7 years ago
Thanks for your reply - gjoubert 7 years ago
-Corey - cserrins 7 years ago
Thanks you so far and cheers - ybnA 6 years ago
2019-02-12 12:58:18 : Start of Get ComputerName log entry for 2019-02-12
2019-02-12 12:58:18 : ============================================
2019-02-12 12:58:18 :
2019-02-12 12:58:18 : Drive letter with registry is c:
2019-02-12 12:58:18 : Dialog box option is set to: False
2019-02-12 12:58:20 : The computer name in the registry is: NAMETEST
2019-02-12 12:58:20 : MAC Address of system is: 080027BEEE17
2019-02-12 12:58:20 : Full MAC Address is: 08:00:27:BE:EE:17
2019-02-12 12:58:21 : GetComputerName wrote the file x:\080027BEEE17
2019-02-12 12:58:21 : Computer Name written to file: NAMETEST
2019-02-12 12:58:21 :
2019-02-12 12:58:21 : ============================================
2019-02-12 12:58:21 : End of Get ComputerName log entry
2019-02-12 12:58:21 : ============================================
2019-02-12 13:11:07 : ==================================================
2019-02-12 13:11:07 : Start of Set ComputerName log entry for 2019-02-12
2019-02-12 13:11:07 : ==================================================
2019-02-12 13:11:07 :
2019-02-12 13:11:07 : Command line parameters: /log
2019-02-12 13:11:07 :
2019-02-12 13:11:08 : Sysprepped = True
2019-02-12 13:11:13 : Getting OS information from drive letter: c:
2019-02-12 13:11:13 : Product Name: Windows 10 Education
2019-02-12 13:11:13 : Edition ID: Education
2019-02-12 13:11:13 : InstallationType: Client
2019-02-12 13:11:13 : Build Number: 17763
2019-02-12 13:11:13 : Kernel Build: 6.3
2019-02-12 13:11:13 : Major Version Number: 10
2019-02-12 13:11:13 : Minor Version Number: 0
2019-02-12 13:11:13 : MAC Address of system is: 080027BEEE17
2019-02-12 13:11:13 : Full MAC Address is: 08:00:27:BE:EE:17
2019-02-12 13:11:13 : OS name is W10
2019-02-12 13:11:13 : Computer Serial Number #: 0
2019-02-12 13:11:13 : Computer Manufacturer: innotek
2019-02-12 13:11:13 : Computer Model is VirtualBox
2019-02-12 13:11:13 : Chassis type: VM
2019-02-12 13:11:13 : ChassisAbr type: VM
2019-02-12 13:11:13 : Asset tag is
2019-02-12 13:11:13 : Computer Name found on x:\ Drive and the name in the file is: NAMETEST
2019-02-12 13:11:13 : Found unattend in panther of system image
2019-02-12 13:11:13 : Found unattend in sysprep directory of system image
2019-02-12 13:11:13 : The file storing the computername was deleted from drive x:
2019-02-12 13:11:13 :
2019-02-12 13:11:13 : ==================================================
2019-02-12 13:11:13 : End of Set ComputerName log entry
2019-02-12 13:11:13 : ==================================================
2019-02-12 13:11:13 :
2019-02-12 13:11:13 : Log file was moved to workstation - kzhangmit 5 years ago
What value is the computername node supposed to have? - kzhangmit 5 years ago
It seems that the last version (2.0.0.4) has not been published yet to the Quest website. It's still version 2.0.0.0.
Do you know why it's the case ? - marc_c 4 years ago
When do you plan to post the new setup. The added features in v2.0.0.4 are just what I need.
Thanks - DLCurtis 4 years ago
Thank you so very much for getting this updated. It is just a great tool that we use all the time. - DLCurtis 4 years ago
First Error:
Y:\application\143\setcomputername_x64.exe
COM Error with DOM!
err.discription is:
err.windescription: Variable must be of type 'Object'.
err.number is: 000000A9
err.lastdllerror is: 0
err.source is: -1
err.helpfile is:
errhelpcontext is:
Second Error:
Autolt Error
Line 5864 (File "Y:\applications\143\setcomputername_x64.exe"):
Error: Variable must be of type 'Object". - smuesse 4 years ago