jpodlipny Posted February 16, 2012 Report post Posted February 16, 2012 I'm trying to write a simple script that would first check at logon if a user is on our domain and if so, launch a website. This is so that they don't get "Page cannot be displayed" if they are not connected. So far I'm playing with: ipconfig > c:\IP.txt FINDSTR "10.5" c:\IP.txt > C:\Subnet.txt Now how would I use the IF command to check if 10.5 is present in the "Subnet.txt" and if so, launch the site? This is probably very simple but my knowledge of scripts is limited to Google. Thanks! Quote Share this post Link to post Share on other sites More sharing options...
0 jpodlipny Posted March 7, 2012 Report post Posted March 7, 2012 Anybody? How would you go about checking an IP address and then launch a website? Quote Share this post Link to post Share on other sites More sharing options...
0 Lucid Posted March 20, 2012 Report post Posted March 20, 2012 My batch file scripting is too rusty, so if you're not stuck on that, here's some quick VBScript code to do what you're looking for: Option Explicit Dim objWshShell, RegExp, objWMIService, colNetAdapters, objItem, strSubnetCheck Set objWshShell = WScript.CreateObject("WScript.Shell") Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\.\root\cimv2") Set RegExp = new RegExp RegExp.IgnoreCase = true strSubnetCheck = "unknown" Set colNetAdapters = objWMIService.ExecQuery ("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled=True") For Each objItem In colNetAdapters RegExp.pattern = "10.5" If (RegExp.test (objItem.IPSubnet(0)) = TRUE) Then strSubnetCheck = "OnSubnet" End If Next If UCase(strSubnetCheck) = UCase("OnSubnet") Then objWshShell.Run("http://www.windows-noob.com") End If Wscript.Quit 1 Quote Share this post Link to post Share on other sites More sharing options...
0 I-MANjuel Posted March 25, 2012 Report post Posted March 25, 2012 And here's the commandline code: ipconfig | find /i "10.5" IF NOT errorlevel 1 start http://www.windows-noob.com 1 Quote Share this post Link to post Share on other sites More sharing options...
0 jpodlipny Posted March 26, 2012 Report post Posted March 26, 2012 Lucid / I-MANjuel, Thanks so much for your answers. This was very helpful. As I suspected, the BATCH script was very simple and does the job perfectly! Thanks Quote Share this post Link to post Share on other sites More sharing options...
I'm trying to write a simple script that would first check at logon if a user is on our domain and if so, launch a website.
This is so that they don't get "Page cannot be displayed" if they are not connected.
So far I'm playing with:
ipconfig > c:\IP.txt
FINDSTR "10.5" c:\IP.txt > C:\Subnet.txt
Now how would I use the IF command to check if 10.5 is present in the "Subnet.txt" and if so, launch the site?
This is probably very simple but my knowledge of scripts is limited to Google.
Thanks!
Share this post
Link to post
Share on other sites