Solved

Batch File for logon script to check Static IP Settings

Posted on 2011-03-01
12
585 Views
Last Modified: 2012-08-13
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.
0
Comment
Question by:speeDemon
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +4
12 Comments
 
LVL 3

Expert Comment

by:Rhyseh
ID: 35013099
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
 
LVL 1

Author Comment

by:speeDemon
ID: 35013331
we are not using DHCP fo Addresses everyhting is staticly assigned
0
 
LVL 96

Expert Comment

by:Lee W, MVP
ID: 35013531
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
Major Incident Management Communications

Major incidents and IT service outages cost companies millions. Often the solution to minimizing damage is automated communication. Find out more in our Major Incident Management Communications infographic.

 
LVL 96

Expert Comment

by:Lee W, MVP
ID: 35013543
I will say doing this will require the use of netsh
0
 
LVL 4

Expert Comment

by:cmartell
ID: 35013953
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
 
LVL 14

Expert Comment

by:Don Thomson
ID: 35015927
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
 
LVL 8

Expert Comment

by:MarkieS
ID: 35015936
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
 
LVL 1

Author Comment

by:speeDemon
ID: 35019989
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
 
LVL 14

Expert Comment

by:Don Thomson
ID: 35020341
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
 
LVL 96

Expert Comment

by:Lee W, MVP
ID: 35020655
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
 
LVL 47

Accepted Solution

by:
Donald Stewart earned 500 total points
ID: 35077551
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
Over the years I've spent many an hour playing on hardened, DMZ'd servers, with only a sub-set of the usual GNU toy's to keep me company; frequently I've needed to save and send log or data extracts from these server back to my PC, or to others, and…
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question