esprimo Posted April 3, 2008 Share Posted April 3, 2008 Dear readers,Sorry for my english but i am trying to do my best I need a VB script or Batch script that does the following thing :I want that the computername changed automatic, and i hope that it is possible that the names read from a list from a txt file,Sample :If name exist then nextpc01-3-brinif exist thenpc02-3-brinpc01-3-brin not exist then it's the new computer nameI hope you will understeand me,Thank you guy's Link to comment Share on other sites More sharing options...
IcemanND Posted April 3, 2008 Share Posted April 3, 2008 What do you mean by "if exist xxxx" if the name already exists on the network? or if it is in the text file?If it is that it is on the network this will only work if all the machines are on, otherwise you won;t be able to know if MachineNameX exists. It would be better if you have a DHCP server that you can query against to get the registered machine name and rename it according to that, or associate something with the machine to the machine name like a serial number that could be looked up with WMI. Link to comment Share on other sites More sharing options...
tguy Posted April 24, 2008 Share Posted April 24, 2008 If you want to see if the machine is live on the network you could do as IceManND suggests and query a DHCP server or ping the list of servers in your batch file until you find the one(s) that do not respond.This may not necessarily be accurate if the machine is powered off and/or has been powered off long enough for its DHCP lease to expire.You could also do a Netbios query, or query a WINS server to see if there are any responses for the computers in your list.If you are running Active Directory or have an NT domain you could use ADSI queries or NT resource kit utilities to see if a computer account already exists.Hope this helps as well. Link to comment Share on other sites More sharing options...
Smiley357 Posted April 24, 2008 Share Posted April 24, 2008 (edited) @echo offfind /i "computername" c:\test.txt > nulif errorlevel 1 goto notfoundgoto :found:foundget new name here:notfoundrename computer hereIm not exactly sure how you plan on getting names or how you want to change computer name but this can test the txt file like you wantedIf the computername is already set and that is what you are testing then you can replace computername with %COMPUTERNAME%. Edited April 24, 2008 by Smiley357 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now