Automatically rename computers based on their MAC address
How to automatically rename a computer host / name based on it's MAC address?
I have 40 PC's and I need a script to rename them automatically at logon after I use ghost.
I'm in a Windows 7 environment.
automation rename mac-address hostname
add a comment |
How to automatically rename a computer host / name based on it's MAC address?
I have 40 PC's and I need a script to rename them automatically at logon after I use ghost.
I'm in a Windows 7 environment.
automation rename mac-address hostname
1
Adding the operating system running on them might be a good idea.
– Mario
Jul 18 '13 at 10:31
Have you considered using DHCP?
– Scott
Jul 18 '13 at 16:05
I am using Linux server with Win clients. I use dhcp to assign ip basedd on each MAC. Can I use dhcp to configure Windows host name?
– apo
Jul 19 '13 at 8:57
add a comment |
How to automatically rename a computer host / name based on it's MAC address?
I have 40 PC's and I need a script to rename them automatically at logon after I use ghost.
I'm in a Windows 7 environment.
automation rename mac-address hostname
How to automatically rename a computer host / name based on it's MAC address?
I have 40 PC's and I need a script to rename them automatically at logon after I use ghost.
I'm in a Windows 7 environment.
automation rename mac-address hostname
automation rename mac-address hostname
edited Jan 21 at 23:01
zx485
945813
945813
asked Jul 18 '13 at 10:29
apoapo
615
615
1
Adding the operating system running on them might be a good idea.
– Mario
Jul 18 '13 at 10:31
Have you considered using DHCP?
– Scott
Jul 18 '13 at 16:05
I am using Linux server with Win clients. I use dhcp to assign ip basedd on each MAC. Can I use dhcp to configure Windows host name?
– apo
Jul 19 '13 at 8:57
add a comment |
1
Adding the operating system running on them might be a good idea.
– Mario
Jul 18 '13 at 10:31
Have you considered using DHCP?
– Scott
Jul 18 '13 at 16:05
I am using Linux server with Win clients. I use dhcp to assign ip basedd on each MAC. Can I use dhcp to configure Windows host name?
– apo
Jul 19 '13 at 8:57
1
1
Adding the operating system running on them might be a good idea.
– Mario
Jul 18 '13 at 10:31
Adding the operating system running on them might be a good idea.
– Mario
Jul 18 '13 at 10:31
Have you considered using DHCP?
– Scott
Jul 18 '13 at 16:05
Have you considered using DHCP?
– Scott
Jul 18 '13 at 16:05
I am using Linux server with Win clients. I use dhcp to assign ip basedd on each MAC. Can I use dhcp to configure Windows host name?
– apo
Jul 19 '13 at 8:57
I am using Linux server with Win clients. I use dhcp to assign ip basedd on each MAC. Can I use dhcp to configure Windows host name?
– apo
Jul 19 '13 at 8:57
add a comment |
1 Answer
1
active
oldest
votes
This is quite an old (February 2009) article: Script to change computer name based on MAC address
at Microsoft’s Scripting forums. I used it a couple of years ago.
Sub ChangeCompName(strComputer,Seg,IP)
'==============================================================================================
'This Sub Changes the Computer Name according to a Constant Value and the IP address entered
'It Changes the ComputerName key in the Registry and some other keys to do so
'==============================================================================================
const HKEY_LOCAL_MACHINE = &H80000002
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\" &_
strComputer & "rootdefault:StdRegProv")
strKeyPath = "SYSTEMCurrentControlSetControlComputerNameComputerName"
strValueName = "ComputerName"
strValue = "CompName" & seg & IP
oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
strKeyPath = "SYSTEMCurrentControlSetServicesTcpipParameters"
strValueName = "Hostname"
strValue = "CompName" & seg & IP
oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
strKeyPath = "SYSTEMCurrentControlSetServicesTcpipParameters"
strValueName = "NV Hostname"
strValue = "CompName" & seg & IP
oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
objFile.WriteLine "Computer Name: " & strValue
'==============================================================================================
'Write the new computer name to the Log
'==============================================================================================
End Sub
1
Note: As stated in the article (from which this script was copied) and in the comments in the script itself, this works with IP address (or at least it claims to), rather than MAC address as requested. Worse, it appears to take the IP address as a parameter. Can you explain how the OP would invoke this script, and how the invoking method could obtain the MAC address?
– Scott
Jul 18 '13 at 16:04
I have to use a batch file to run straight after the ghost and all the parameters should be in a single .txt file (ex. 00-00-00-00-01=pc-01 etc).
– apo
Jul 19 '13 at 7:16
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f621299%2fautomatically-rename-computers-based-on-their-mac-address%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
This is quite an old (February 2009) article: Script to change computer name based on MAC address
at Microsoft’s Scripting forums. I used it a couple of years ago.
Sub ChangeCompName(strComputer,Seg,IP)
'==============================================================================================
'This Sub Changes the Computer Name according to a Constant Value and the IP address entered
'It Changes the ComputerName key in the Registry and some other keys to do so
'==============================================================================================
const HKEY_LOCAL_MACHINE = &H80000002
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\" &_
strComputer & "rootdefault:StdRegProv")
strKeyPath = "SYSTEMCurrentControlSetControlComputerNameComputerName"
strValueName = "ComputerName"
strValue = "CompName" & seg & IP
oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
strKeyPath = "SYSTEMCurrentControlSetServicesTcpipParameters"
strValueName = "Hostname"
strValue = "CompName" & seg & IP
oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
strKeyPath = "SYSTEMCurrentControlSetServicesTcpipParameters"
strValueName = "NV Hostname"
strValue = "CompName" & seg & IP
oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
objFile.WriteLine "Computer Name: " & strValue
'==============================================================================================
'Write the new computer name to the Log
'==============================================================================================
End Sub
1
Note: As stated in the article (from which this script was copied) and in the comments in the script itself, this works with IP address (or at least it claims to), rather than MAC address as requested. Worse, it appears to take the IP address as a parameter. Can you explain how the OP would invoke this script, and how the invoking method could obtain the MAC address?
– Scott
Jul 18 '13 at 16:04
I have to use a batch file to run straight after the ghost and all the parameters should be in a single .txt file (ex. 00-00-00-00-01=pc-01 etc).
– apo
Jul 19 '13 at 7:16
add a comment |
This is quite an old (February 2009) article: Script to change computer name based on MAC address
at Microsoft’s Scripting forums. I used it a couple of years ago.
Sub ChangeCompName(strComputer,Seg,IP)
'==============================================================================================
'This Sub Changes the Computer Name according to a Constant Value and the IP address entered
'It Changes the ComputerName key in the Registry and some other keys to do so
'==============================================================================================
const HKEY_LOCAL_MACHINE = &H80000002
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\" &_
strComputer & "rootdefault:StdRegProv")
strKeyPath = "SYSTEMCurrentControlSetControlComputerNameComputerName"
strValueName = "ComputerName"
strValue = "CompName" & seg & IP
oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
strKeyPath = "SYSTEMCurrentControlSetServicesTcpipParameters"
strValueName = "Hostname"
strValue = "CompName" & seg & IP
oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
strKeyPath = "SYSTEMCurrentControlSetServicesTcpipParameters"
strValueName = "NV Hostname"
strValue = "CompName" & seg & IP
oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
objFile.WriteLine "Computer Name: " & strValue
'==============================================================================================
'Write the new computer name to the Log
'==============================================================================================
End Sub
1
Note: As stated in the article (from which this script was copied) and in the comments in the script itself, this works with IP address (or at least it claims to), rather than MAC address as requested. Worse, it appears to take the IP address as a parameter. Can you explain how the OP would invoke this script, and how the invoking method could obtain the MAC address?
– Scott
Jul 18 '13 at 16:04
I have to use a batch file to run straight after the ghost and all the parameters should be in a single .txt file (ex. 00-00-00-00-01=pc-01 etc).
– apo
Jul 19 '13 at 7:16
add a comment |
This is quite an old (February 2009) article: Script to change computer name based on MAC address
at Microsoft’s Scripting forums. I used it a couple of years ago.
Sub ChangeCompName(strComputer,Seg,IP)
'==============================================================================================
'This Sub Changes the Computer Name according to a Constant Value and the IP address entered
'It Changes the ComputerName key in the Registry and some other keys to do so
'==============================================================================================
const HKEY_LOCAL_MACHINE = &H80000002
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\" &_
strComputer & "rootdefault:StdRegProv")
strKeyPath = "SYSTEMCurrentControlSetControlComputerNameComputerName"
strValueName = "ComputerName"
strValue = "CompName" & seg & IP
oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
strKeyPath = "SYSTEMCurrentControlSetServicesTcpipParameters"
strValueName = "Hostname"
strValue = "CompName" & seg & IP
oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
strKeyPath = "SYSTEMCurrentControlSetServicesTcpipParameters"
strValueName = "NV Hostname"
strValue = "CompName" & seg & IP
oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
objFile.WriteLine "Computer Name: " & strValue
'==============================================================================================
'Write the new computer name to the Log
'==============================================================================================
End Sub
This is quite an old (February 2009) article: Script to change computer name based on MAC address
at Microsoft’s Scripting forums. I used it a couple of years ago.
Sub ChangeCompName(strComputer,Seg,IP)
'==============================================================================================
'This Sub Changes the Computer Name according to a Constant Value and the IP address entered
'It Changes the ComputerName key in the Registry and some other keys to do so
'==============================================================================================
const HKEY_LOCAL_MACHINE = &H80000002
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\" &_
strComputer & "rootdefault:StdRegProv")
strKeyPath = "SYSTEMCurrentControlSetControlComputerNameComputerName"
strValueName = "ComputerName"
strValue = "CompName" & seg & IP
oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
strKeyPath = "SYSTEMCurrentControlSetServicesTcpipParameters"
strValueName = "Hostname"
strValue = "CompName" & seg & IP
oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
strKeyPath = "SYSTEMCurrentControlSetServicesTcpipParameters"
strValueName = "NV Hostname"
strValue = "CompName" & seg & IP
oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
objFile.WriteLine "Computer Name: " & strValue
'==============================================================================================
'Write the new computer name to the Log
'==============================================================================================
End Sub
edited Jul 18 '13 at 16:02
Scott
15.8k113990
15.8k113990
answered Jul 18 '13 at 10:47
admintechadmintech
6,72812241
6,72812241
1
Note: As stated in the article (from which this script was copied) and in the comments in the script itself, this works with IP address (or at least it claims to), rather than MAC address as requested. Worse, it appears to take the IP address as a parameter. Can you explain how the OP would invoke this script, and how the invoking method could obtain the MAC address?
– Scott
Jul 18 '13 at 16:04
I have to use a batch file to run straight after the ghost and all the parameters should be in a single .txt file (ex. 00-00-00-00-01=pc-01 etc).
– apo
Jul 19 '13 at 7:16
add a comment |
1
Note: As stated in the article (from which this script was copied) and in the comments in the script itself, this works with IP address (or at least it claims to), rather than MAC address as requested. Worse, it appears to take the IP address as a parameter. Can you explain how the OP would invoke this script, and how the invoking method could obtain the MAC address?
– Scott
Jul 18 '13 at 16:04
I have to use a batch file to run straight after the ghost and all the parameters should be in a single .txt file (ex. 00-00-00-00-01=pc-01 etc).
– apo
Jul 19 '13 at 7:16
1
1
Note: As stated in the article (from which this script was copied) and in the comments in the script itself, this works with IP address (or at least it claims to), rather than MAC address as requested. Worse, it appears to take the IP address as a parameter. Can you explain how the OP would invoke this script, and how the invoking method could obtain the MAC address?
– Scott
Jul 18 '13 at 16:04
Note: As stated in the article (from which this script was copied) and in the comments in the script itself, this works with IP address (or at least it claims to), rather than MAC address as requested. Worse, it appears to take the IP address as a parameter. Can you explain how the OP would invoke this script, and how the invoking method could obtain the MAC address?
– Scott
Jul 18 '13 at 16:04
I have to use a batch file to run straight after the ghost and all the parameters should be in a single .txt file (ex. 00-00-00-00-01=pc-01 etc).
– apo
Jul 19 '13 at 7:16
I have to use a batch file to run straight after the ghost and all the parameters should be in a single .txt file (ex. 00-00-00-00-01=pc-01 etc).
– apo
Jul 19 '13 at 7:16
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f621299%2fautomatically-rename-computers-based-on-their-mac-address%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Adding the operating system running on them might be a good idea.
– Mario
Jul 18 '13 at 10:31
Have you considered using DHCP?
– Scott
Jul 18 '13 at 16:05
I am using Linux server with Win clients. I use dhcp to assign ip basedd on each MAC. Can I use dhcp to configure Windows host name?
– apo
Jul 19 '13 at 8:57