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!
Answers (1)
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)
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 3 years ago
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: 192.168.69.240 /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 3 years ago