Use the setcomputername task twice

Good morning all!

I should run the setcomputername SDA task twice during a scripted installation. Indeed, this would allow me to be able to recover either a name given by the administrator or a name found in the database.

The tasks therefore follow this order:


Get Computer Name With Timeout prompts the technician for a name. If the technician does not want to give a name, after 2 minutes he returns a random number.

Set Computer Name With K1 DB looks up the computer name in the K1 database.

Set Computer Name - Random retrieves the name given by the technician. If this name is random, it will not be used and we will therefore keep the name entered in the second step (the old one).

However, I have a problem: the file in which the name the technician left is cleared by the second step (Set Computer Name With K1 DB).

By using the switch /debug, I am offered if I want to delete this file. Is there a way to achieve this with commands? I did not find anything on the subject in the documentation.

I also thought about using the switch /drive:c for steps 1 and 3. The file is still deleted by the 2nd step.

Thanks everyone!

1 Comment   [ + ] Show comment
  • You should post the info about the switches.

    Anyhow, I've never seen two Set Computernames in Place.
    Both EXEs are looking at the same file, and if the file name is consumed, it will be destroyed by SetComputerName EXE.

    You do know that GetComputerName, was designed to Retain the existing hostname in the first place?

    Is this not enough? (vs. having to lookup the name in the SMA DB). - Channeler 1 year ago
    • Hi, thanks for the reply

      Regarding the information on the switches:
      Get Computer Name With Timeout : getcomputername_x64.exe /timeout: 120 /dialog
      Set Computer Name With K1 DB : setcomputername_x64.exe /k1mysql /k1ipaddress: /k1dbname: ORG1 /k1dbuser: ******* /k1dbpass: ******* /notrandom
      Set Computer Name - Random : setcomputername_x64.exe /notrandom

      > Both EXEs are looking at the same file, and if the file name is consumed, it will be destroyed by SetComputerName EXE.
      Indeed, and this is the basis of my problems... This is why I am looking for a way to move or to protect the file when running the first SetComputerName.

      > You do know that GetComputerName, was designed to Retain the existing hostname in the first place?
      Yes I know. However, using the switch / timeout, according to the documentation, then the stored name will be a random name and not the original name...

      > Is this not enough?
      Additionally, some of our users have administrator privileges allowing them to change their own hostname when they leave the network. We must therefore not use a name whose conformity is not certified. - superdada 1 year ago

Answers (1)

Answer Summary:
Posted by: Mashby1 1 year ago
Orange Belt

Top Answer

So A diskpart will most certainly wipe the data on C:
According to the documentation 

How getcomputername.exe works:

1. The active nic is found and the MAC address recorded.

2. The registry and loaded and we read the computername of the workstation

3. If /dialog was chosen, this name is entered in the dialog by default, if no name found then we use *,

   whatever is in the dialog box at the time OK is clicked, that will be used as the computername

4. A file is created on the T: drive (petemp) with the MAC address as its name.

5. The computer name is recorded inside the file in step 4.

So it *should* be using T: to store the name. Are you able to run the /log and provide it? It may have further clues as to what is happening. 
Also the blog post could be a good place to ask this question on here: Article: Get/Set ComputerName (itninja.com)

This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ