(Windows 8.1) Launch a specific software if IP address is 192.168.49.*

1

I know there's is a way to launch an executable when specific condition are met, but i'm not familiar with programming.

Is there a way to launch a software, in my case Skype For Business if my local ip is within a subnet (e.g. 192.168.49.*). I only want to make this works only if my Local Area Network card is connected to that subnet.

Correct me if i'm wrong but, I think the best way to do so would be to trigger a vbs file like 30 seconds after the logon using windows task manager.

I'm not able to craft that kind of script and my google searches haven't been successful !

Thanks guys !

Jonathan R.

Posted 2015-08-02T03:04:17.957

Reputation: 13

Answers

0

How do I run a program if my local ip is within a subnet?

For example 192.168.49.*

The following batch file will run notepad if your local IP address is in the range 192.168.49.*:

@echo off
setlocal
rem get ip address
for /f "delims=[] tokens=2" %%a in ('ping -4 %computername% -n 1 ^| findstr "["') do set _ip=%%a
rem get subnet
for /f "tokens=1-3 delims=." %%b in ("%_ip%") do set _subnet=%%b.%%c.%%d
rem check for matching subnet
if [%_subnet%] equ [192.168.49] notepad

Notes:

  • replace notepad with the name of the program you want to run.
  • place a copy of the batch file in %APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup to run on login.

Further Reading

  • An A-Z Index of the Windows CMD command line - An excellent reference for all things Windows cmd line related.
  • environment variables - Environment variables are mainly used within batch files, they can be created, modified and deleted for a session using the SET command.
  • findstr - Search for strings in files.
  • for /f - Loop command against the results of another command.
  • set - Display, set, or remove CMD environment variables. Changes made with SET will remain only for the duration of the current CMD session.
  • setlocal - Set options to control the visibility of environment variables in a batch file.

DavidPostill

Posted 2015-08-02T03:04:17.957

Reputation: 118 938