Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Batch File for logon script to check Static IP Settings

Posted on 2011-03-01
12
Medium Priority
?
599 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
  • 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
Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

 
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 2000 total points
ID: 35077551
0

Featured Post

Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

Question has a verified solution.

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

YESTERDAY YESTERDAY.BAT is inspired by a previous article I wrote entitled: TOMORROW.BAT (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/A_4196-Advanced-Batch-File-Programming-TOMORROW-BAT.html). The crux of this batch f…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

927 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