MSFN Forum: Help ! .. Change pc name automatic from txt - MSFN Forum

Jump to content



Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Help ! .. Change pc name automatic from txt Rate Topic: -----

#1 User is offline   esprimo 

  • Group: Members
  • Posts: 1
  • Joined: 03-April 08

Posted 03 April 2008 - 12:58 AM

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


#2 User is offline   IcemanND 

  • MSFN Junkie
  • Group: Super Moderator
  • Posts: 3,239
  • Joined: 24-September 03
  • OS:Windows 7 x64
  • Country: Country Flag

Posted 03 April 2008 - 07:38 AM

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.

#3 User is offline   tguy 

  • Senior Member
  • PipPipPipPip
  • Group: Members
  • Posts: 698
  • Joined: 19-May 04

Posted 24 April 2008 - 12:52 PM

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.

#4 User is offline   Smiley357 

  • Junior
  • Pip
  • Group: Members
  • Posts: 85
  • Joined: 12-October 07

Posted 24 April 2008 - 02:08 PM

 
@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%.

This post has been edited by Smiley357: 24 April 2008 - 02:14 PM


Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2011 msfn.org
Privacy Policy