Jump to content

Help ! .. Change pc name automatic from txt


Recommended Posts

Dear readers,

Sorry for my english but i am trying to do my best :blushing:

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 next

pc01-3-brin

if exist then

pc02-3-brin

pc01-3-brin not exist then it's the new computer name

I hope you will understeand me,

Thank you guy's

Link to comment
Share on other sites


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

  • 3 weeks later...

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

@echo off

find /i "computername" c:\test.txt > nul
if errorlevel 1 goto notfound
goto :found

:found
get new name here

:notfound
rename computer here

Im 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 wanted

If the computername is already set and that is what you are testing then you can replace computername with %COMPUTERNAME%.

Edited by Smiley357
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...