![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Script to run only on a given subnet Is it possible to write a startup script that will run a program such as BGinfo only if the computer is on one of a list of specified subnets? For instance, I want my laptops to run this program only if they are connected to my network internally. When they try to run them from the outside, they get an error message that the SQL server can't be contacted, which of course it can't because they aren't on the network. Thanks. |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Script to run only on a given subnet "Glenn" <nospam@xxxxxx> wrote in message news:uNIoyUOhJHA.5244@xxxxxx Quote: > Is it possible to write a startup script that will run a program such as > BGinfo only if the computer is on one of a list of specified subnets? > > For instance, I want my laptops to run this program only if they are > connected to my network internally. > > When they try to run them from the outside, they get an error message that > the SQL server can't be contacted, which of course it can't because they > aren't on the network. > > Thanks. It assumes that "192.168.1" is your internal subnet address. ipconfig | find /i "IP_Address" | find /i "192.168.1" && "c:\Program Files\My Folder\My Prog.exe" If you prefer a chatty solution then you can built it on this VB Script: Set oWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\.\root\cimv2") Set cNicConfigs = oWMIService.ExecQuery("SELECT * FROM " _ & "Win32_NetworkAdapterConfiguration WHERE IPEnabled = True") For Each oNICConfig In cNicConfigs For Each sIPAddress In oNICConfig.IPAddress WScript.Echo "Subnet = " & Left(sIPAddress, InStrRev(sIPAddress, ".")-1) Next Next |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Script to run only on a given subnet I am trying the simple solution, but it doesn't work. Here's exactly what I am typing. (my ip address is 172.16.31.155) ipconfig | find /i "IP_Address" | find /i "172.16.31" && "bginfo c:\bginfo\mysetup.bgi /timer:0" But it doesn't run. If i type the bginfo c:\bginfo\mysetup.bgi /timer:0 on a line by itself it works fine. Thanks for any direction you can provide me. "Pegasus (MVP)" <I.can@xxxxxx> wrote in message news:uJA$wGThJHA.3812@xxxxxx Quote: > > "Glenn" <nospam@xxxxxx> wrote in message > news:uNIoyUOhJHA.5244@xxxxxx Quote: >> Is it possible to write a startup script that will run a program such as >> BGinfo only if the computer is on one of a list of specified subnets? >> >> For instance, I want my laptops to run this program only if they are >> connected to my network internally. >> >> When they try to run them from the outside, they get an error message >> that the SQL server can't be contacted, which of course it can't because >> they aren't on the network. >> >> Thanks. > The simplest solution is to insert this line into your startup batch file. > It assumes that "192.168.1" is your internal subnet address. > > ipconfig | find /i "IP_Address" | find /i "192.168.1" && "c:\Program > Files\My Folder\My Prog.exe" > > If you prefer a chatty solution then you can built it on this VB Script: > > Set oWMIService = GetObject("winmgmts:" _ > & "{impersonationLevel=impersonate}!\\.\root\cimv2") > Set cNicConfigs = oWMIService.ExecQuery("SELECT * FROM " _ > & "Win32_NetworkAdapterConfiguration WHERE IPEnabled = True") > For Each oNICConfig In cNicConfigs > For Each sIPAddress In oNICConfig.IPAddress > WScript.Echo "Subnet = " & Left(sIPAddress, InStrRev(sIPAddress, ".")-1) > Next > Next > > |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Script to run only on a given subnet disregard I found the error. no _ between IP & Address. "Glenn" <nospam@xxxxxx> wrote in message news:ey$Yw2hiJHA.3708@xxxxxx Quote: >I am trying the simple solution, but it doesn't work. > > Here's exactly what I am typing. (my ip address is 172.16.31.155) > > ipconfig | find /i "IP_Address" | find /i "172.16.31" && "bginfo > c:\bginfo\mysetup.bgi /timer:0" > > But it doesn't run. > > If i type the bginfo c:\bginfo\mysetup.bgi /timer:0 on a line by itself it > works fine. > > Thanks for any direction you can provide me. > > > "Pegasus (MVP)" <I.can@xxxxxx> wrote in message > news:uJA$wGThJHA.3812@xxxxxx Quote: >> >> "Glenn" <nospam@xxxxxx> wrote in message >> news:uNIoyUOhJHA.5244@xxxxxx Quote: >>> Is it possible to write a startup script that will run a program such as >>> BGinfo only if the computer is on one of a list of specified subnets? >>> >>> For instance, I want my laptops to run this program only if they are >>> connected to my network internally. >>> >>> When they try to run them from the outside, they get an error message >>> that the SQL server can't be contacted, which of course it can't because >>> they aren't on the network. >>> >>> Thanks. >> The simplest solution is to insert this line into your startup batch >> file. It assumes that "192.168.1" is your internal subnet address. >> >> ipconfig | find /i "IP_Address" | find /i "192.168.1" && "c:\Program >> Files\My Folder\My Prog.exe" >> >> If you prefer a chatty solution then you can built it on this VB Script: >> >> Set oWMIService = GetObject("winmgmts:" _ >> & "{impersonationLevel=impersonate}!\\.\root\cimv2") >> Set cNicConfigs = oWMIService.ExecQuery("SELECT * FROM " _ >> & "Win32_NetworkAdapterConfiguration WHERE IPEnabled = True") >> For Each oNICConfig In cNicConfigs >> For Each sIPAddress In oNICConfig.IPAddress >> WScript.Echo "Subnet = " & Left(sIPAddress, InStrRev(sIPAddress, ".")-1) >> Next >> Next >> >> > |
My System Specs![]() |
| | #5 (permalink) |
| | Re: Script to run only on a given subnet "Glenn" <nospam@xxxxxx> wrote in message news:%23AlIIamiJHA.1172@xxxxxx Quote: > disregard I found the error. no _ between IP & Address. /Al Quote: > "Glenn" <nospam@xxxxxx> wrote in message > news:ey$Yw2hiJHA.3708@xxxxxx Quote: >>I am trying the simple solution, but it doesn't work. >> >> Here's exactly what I am typing. (my ip address is 172.16.31.155) >> >> ipconfig | find /i "IP_Address" | find /i "172.16.31" && "bginfo >> c:\bginfo\mysetup.bgi /timer:0" >> >> But it doesn't run. >> >> If i type the bginfo c:\bginfo\mysetup.bgi /timer:0 on a line by itself >> it works fine. >> >> Thanks for any direction you can provide me. >> >> >> "Pegasus (MVP)" <I.can@xxxxxx> wrote in message >> news:uJA$wGThJHA.3812@xxxxxx Quote: >>> >>> "Glenn" <nospam@xxxxxx> wrote in message >>> news:uNIoyUOhJHA.5244@xxxxxx >>>> Is it possible to write a startup script that will run a program such >>>> as BGinfo only if the computer is on one of a list of specified >>>> subnets? >>>> >>>> For instance, I want my laptops to run this program only if they are >>>> connected to my network internally. >>>> >>>> When they try to run them from the outside, they get an error message >>>> that the SQL server can't be contacted, which of course it can't >>>> because they aren't on the network. >>>> >>>> Thanks. >>> >>> The simplest solution is to insert this line into your startup batch >>> file. It assumes that "192.168.1" is your internal subnet address. >>> >>> ipconfig | find /i "IP_Address" | find /i "192.168.1" && "c:\Program >>> Files\My Folder\My Prog.exe" >>> >>> If you prefer a chatty solution then you can built it on this VB Script: >>> >>> Set oWMIService = GetObject("winmgmts:" _ >>> & "{impersonationLevel=impersonate}!\\.\root\cimv2") >>> Set cNicConfigs = oWMIService.ExecQuery("SELECT * FROM " _ >>> & "Win32_NetworkAdapterConfiguration WHERE IPEnabled = True") >>> For Each oNICConfig In cNicConfigs >>> For Each sIPAddress In oNICConfig.IPAddress >>> WScript.Echo "Subnet = " & Left(sIPAddress, InStrRev(sIPAddress, >>> ".")-1) >>> Next >>> Next >>> >>> >> > |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Windows browsing in an IP subnet with no DC | .NET General | |||
| Vista sharing and subnet | Vista networking & sharing | |||
| IPSec: IP-Rule with subnet | Vista networking & sharing | |||
| Create a subnet in AD | PowerShell | |||
| subnet problem | Vista networking & sharing | |||