I'm writing a batch that I'll remotely place in the all users startup folder using Desktop Central 9 /PsExec. We are going to start using a naming convention as part of an initiative to overhaul computer management. This batch needs to find what the current PC Name is and then change it based off of what I will have manually defined in the batch itself. It would also be nice to be able to then also change the users name based off of what computer name is initially found. All computers use Windows 7 and above. I wrote a quick batch of what I think it should look like, minus the user name modification, but there are nuances here and there I must be getting wrong. The "If" statement is my weakness with batch, but I know it will be extremely efficient in this case. Can anyone correct what I'm doing wrong here? Much appreciated, this will help us A LOT!
SET WMIC GET COMPUTERNAME %%CURRENT%
If %%CURRENT% = THOMAS-PC then REG ADD HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName /v ComputerName /t REG_SZ /d TGZ-DELL-001 /f
If %%CURRENT% = CHARLES-PC then REG ADD HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName /v ComputerName /t REG_SZ /d TGZ-DELL-002 /f
If %%CURRENT% = MATHEW-PC then REG ADD HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName /v ComputerName /t REG_SZ /d TGZ-DELL-003 /f
How about something like this? I added /I to make the compare case insensitive. Leave that out if you wish... but then your compare would miss Thomas-PC, etc.
**** CAUTION **** Untested! Of course you will test test on a test machine before messing up the registry on a working machine :)