Batch File for logon script to check Static IP Settings

Hello,

I need a batch file that i can run at logon to check a PC's staticly assigned IP settings, pretty much everyhting but the Ip and if it is wrong i need the batch file to then set the correct IP address based on variables set at the top of the batch file. Hope fully the batch file could figure out which network connection is using the IP address 192.168.1.0 subnet and only set that network cards settings...

If you need more information please let me know.
LVL 1
speeDemonAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
DonConnect With a Mentor Network AdministratorCommented:
0
 
RhysehCommented:
This sounds like a clunky way to do this. Is there a reason you can't create a reservation for the required clients/servers in DHCP and set them to obtain their address automatically?
0
 
speeDemonAuthor Commented:
we are not using DHCP fo Addresses everyhting is staticly assigned
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
Lee W, MVPTechnology and Business Process AdvisorCommented:
Let me rephrase the previous person's question - WHY aren't you using DHCP?

I can try to post instructions later (when I'm not on the phone) but I would like to know as well why you are essentially hacking a dhcp solution instead of just using dhcp
0
 
Lee W, MVPTechnology and Business Process AdvisorCommented:
I will say doing this will require the use of netsh
0
 
cmartellCommented:
If the IPs are statically assigned they aren't going to change so there is no need to check them with a script.

I think we need clarification on your setup and what you are trying to accomplish.
0
 
Don ThomsonCommented:
There is nothing wrong with using static IP's but with today's Servers and Routers, Using Address reservations is much more efficient. If for instance your ISP's DNS server goes south, you only need to change one entry in your Server or router,  On a Domain, the DHCP server will correctly assign the proper routes to DNS servers and Wins servers without having to go into every workstation and setting that up.

Also with the ever increasing use of laptops and desktops, using DHCP with address reservations does make musch more sense

0
 
MarkieSCommented:
Dont continue down this road unless you have a damned good reason too!!!  
The batch file you have requested is DHCP.  

Having said that you dont mention any centrally administered networking so am I guessing you have no servers?

If that's the case anything over 10 local client standalone workgroup machines is going to get to be a headache to administer.  Start thinking of getting a Server and centrally managing your network.
0
 
speeDemonAuthor Commented:
I have servers I am not in a position to change my companies address scheme. I do not have the authority to change clients to DHCP and will have to continue to use staticly assigned IP addresses. The fille will need to check because i do not want the file to continually reset the IP address if the address settings are set in the correct IPs already.

p.s. i totally agree with DHCP, just cant do it because of "higher" powers
0
 
Don ThomsonCommented:
I would do something like

ping %computername% -4 -n 1 >> \\server\logs\iplist

That will give you a list from each PC that logs in - and will append it to a text file on the server
You can probably write a quick and dirty parcing  program to format into whatever structure you want

The actual batch file can be put in the GPO for login scripts on the server

If you just want to see which IP's are assigned to  all the Workstations just  go

Net view > PClist.txt

bring that into excel  as a fixed width file - Kill the comments - and do a search and replace for "\\" with "ping  -4 -n 1 "

Save that as a .txt file and then rename it to getips.bat
then run getips.bat > myiplist

Bring that into your database of what you think should be the IPs  and strip out the garbage - and compare the two lists
0
 
Lee W, MVPTechnology and Business Process AdvisorCommented:
With a clear sample of what you are checking for and changing, it's impossible for me to do this for you (and even then, it would be a logic/coding excersize for me as I've not done something like this via script and only used NETSH on occasion via command line).

Bottom line, to adjust TCP/IP settings you need to use NETSH.  type NETSH /? for online help and you can google NETSH and the first 9 links provided should be quite useful in guiding you how to do what you want.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.