Solved

Batch File for logon script to check Static IP Settings

Posted on 2011-03-01
12
591 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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
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

Cloud Training Guides

FREE GUIDES: In-depth and hand-crafted Linux, AWS, OpenStack, DevOps, Azure, and Cloud training guides created by Linux Academy instructors and the community.

Question has a verified solution.

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

I hope you'll find this tutorial useful and interesting. So let's try to extend Tcl with a new package.  For anyone more deeply interested please check out the book "Practical Programming in Tcl and Tk". It's really one of the best written books abo…
Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

617 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