Page 1 of 1

Own solution: Access Connections autom. profile switching.

Posted: Fri Jul 17, 2009 7:09 am
by Axel
Hi folks,

because I always have had trouble with Access Connection switching my profiles automatically, I made my own solution.
My program surely uses Access Connections and won't replace it.


Background:
The automatic switching between the profiles depending on the current network-environment never works well for me.
Afer reading much about network-adapters and their configuration, I now have an idea why.
Some network-adapters are used multiple times, for example VMware uses them too.
Maybe there is a possible coherence to see, why it works in many environments and but in other not at all.
Further more I recognized, why the automatic profile switching is not working using fixed IP-adress-configurations but with DHCP.
My solution also needs a valid running IP-connection, to determine a default-gateway.
Imagine you configured a fixed-ip-configuration for a customers enviroment, shut down your Thinkpad and boot it in your homenetwork.
This still configured profile, using the fixed IP, for sure will not fit and therefor no default gateway can be found...


First some words about the program:
This is the first running version. It runs well in my environments since some days with no trouble at all.
To be clear: This tool is and will be freeware.
It does NOT change anything in your system. It just reads out the network-environment and tells Access Connections to switch to a specific profile.
So there is no risk using this software. It's running well for me.
But I must point out, that I assume no liability for any problems/damages.
In case of any problems, just ask, I will give support as far as I can.


About my solution:
The tool is based on reading out any valid default gateway from any network-adapter. Thsi also could be more then one.
Then I try to get the MAC-adresses from those found IP-adresses.
Those MAC-adresses then will be compared with the entries of my INI-file.
If any mac-adress matches a configured one, it will be used switch to the regarding Access Connections profile.
The process of anylyzing the network-environment (especially during boot-time) can take some seconds, so I implemented gentle wait-loops.

Because I want to have this happen before a windows-login, I use a free third-party tool to install my program as a windows-service.
The service immediately will be stopped after my program finishes it's work (what lately will happen after a defined maximal waitime) and so it does not use any resources anymore.

For all the user
Who means, it's quite enough running the program after/during windows-login, can place it in the Autostart folder for example.
The Access Connections internal 'automativ switching' should be deactivated for sure.

Overview:
AcProfileSwitcher.exe: The programm itself.
AcProfileSwitcher.ini: the configurationfile.
ACProfileSwitcher.log: the log-file.
RunAsSvc: The folder of the tool used to install my programms as a windows-service.

Details about the INI-file:

Code: Select all

[Application]
MaxWaitTime=120 : The maximum time, the programm tries to find the correct profil regarding to the current netzwork-infrastruktur.
WaitInterval=5 : The waittime between the tries.

[MacToAcProfileMappings] : Mapping between the MAC-adresses of the default-gateways (usually the router) to the Access Connection profiles.
00:AA:BB:CC:DD:EE=Profile1
00:11:22:33:44:55=Profile2

HOWTO: Get the MAC-adresses.
1. Alternative:
- After a first run of my tool, any determined default-gateways MAC-adresses are logged in the LOG-File (see entry "Found Default Gateway Macs:").
2. Alternative:
- Open a DOS-Box.
- Use "ipconfig" to determine the IP-adress of the default-gateway.
- 'Ping' this IP-adress once. Sample: "ping 192.168.168.1"
- Use "arp -a 192.168.168.1" for example to read out the MAC-adress (watch out for "physical adress").


Install as a windows service:
Call the program "RunAsSvc\RunAsSvc.exe" to create a new windows-server like described here exemplarily:
- Displayname: AcProfileSwitcher
- Description: AcProfileSwitcher
- Exe: C:\Program Files\AcProfileSwitcher\AcProfileSwitcher.exe
- WorkingDir: C:\Program Files\AcProfileSwitcher
- Uss "OK"-button to install the service.

Deinstall the service:
You will have a new entry in "System/Software", beginning with "Pirmasoft" and containing the given displayname.

Possible enhancements / ideas:
I think about not only to control Access Connections but for example a program like NetSetMan also.
Calling other software/scripts/actions could also be possible.
Just tell me your ideas. :)

[Download]:
http://rapidshare.com/files/256811808/A ... 1.zip.html


Regards,
Axel