I don't know about you, but one on the thing that bores me the most about being a "MobilePC" user is that I have to do the same things again and again and again and again…
So, this little app is what I have done in an attempt to remove the pain of being a mobile user. Its only purpose is to react to changes in your network environment and try to set your preferences accordingly. Let's say, for the sake of the example, that you use your laptop in 3 distinct places (at home, at work, and in the bus). You certainly change your default printer about 99 times a week, probably swear about that …. proxy you have at work, etc. etc. etc.
Wouldn't it be cool if your laptop just adapted to your environment?
Definitions
NetworkConfiguration : A network configuration is an environment in which your MobilePC can be. Examples of NetworkConfigurations are : « At Home », « At work », « At client X », « Disconnected ». A NetworkConfiguration is defined by its tests – which identifies the state of network settings and the environment – and its netlets –which are commands to execute in order to configure the system.
Tester : A tester is a class that allows to determine if your MobilePC is in a NetworkConfiguration. Examples : « Is My PC connected to DHCP server 192.168.0.1 ?» A NetworkConfiguration is said « active » if all of its tests pass.
Netlet : A netlet is a command that is executed when a NetworkConfiguration is activated or disactivated. Its purpose is to set the environment up, such as changing the default printer, mapping a network drive or moving files to the desktop/start menu.
How does it work?
A small, notification-area-based, application runs in the background of your session and reacts to changes in your network environment. Using Testers, it selects between the configurations that you have set-up which one is currently active, and configures your systems accordingly.
Let's say that you use your laptop in three environments: at home, at work, and on the bus (or anywhere else without a proper network connection); between those three environments, you may want to change some of your settings such as your default printer, the proxy used to connect to Internet, etc. What you need is something like:
Home | Office | Everywhere else (when disconnected) |
Use my inkjet printer | Use a big laser printer | Print to PDF files |
Connect to the internet thru my isp router | Use my corporate proxy | |
Map Z: to \\family\share | | |
| Get shortcuts to my server or applications on my desktop | |
You just have to configure three distinct NetworkConfigurations, and try to define what distinguish one from another. When you have set-up the Testers that uniquely identifies one configuration, you may add one or more Netlets which will change the state of your system.
Home | Office | Everywhere else (when disconnected) |
Testers |
There is a network present | There is a network present | There is no network connection |
My DHCP Server is 192.168.0.254 | My DHCP Server is 10.0.38.253 | |
| | My DNS suffix is mycompany.com | |
Netlets |
Change default printer to My Inkjet | Change default Printer to \\Server\Printer2 | Change default printer to PDFPrint |
Map Drive Z: to \\family\share | | |
| | Copy *.rdp to my Desktop | |
| | Set IE Proxy to 10.0.38.254 | |
A netlet will change to the desired state when a configuration is activated and revert back to the previous state when needed, so you don't have to worry to remove the proxy on IE on the Home profile if it is not set by default.
Configuration
All the configuration of this assistant is done by thru an xml-based settings file which you can edit it from your start menu (Start>All Programs>Network Assistant v0.5>Edit your NetworkConfigurations). Its format is rather simple:
Each NetworkConfiguration must be a child of the root Config element and must have a name attribute.
A NetworkConfiguration should have 2 child elements : Tests and Netlets
In Tests, you can put one of the following elements :
IsConnected
DnsServer
DnsSuffix
DhcpServer
In Netlets, the following child are allowed :
A test element (IsConnected, DnsServer…) have always the same format:
<TestName
value="valueToTest" />
Test name | Value parameter | Remark |
IsConnected | "true" or "false" | If you want the test to pass when a network is available use "true", and if you want to test if the MobilePC is in a disconnected state use "false" |
DhcpServer | IP address | You must use an IP address (192.168.0.1), using a computer hostname is not supported |
DnsServer | IP address | (idem) |
DnsSuffix | Dns suffix | Ex : "carbenay.info" |
The Tests node for the Home configuration is:
<Tests>
<IsConnected
value="true" />
<DnsServer
value="192.168.0.1" />
</Tests>
The netlets have not the same "standard" parameter, and each one is different.
NetletName | Parameter | Remarks |
DefaultPrinter | printerName="{PrinterName} " | |
CopyFiles | sourceFolder="{Path}" | The {Path} parameter can include environment variables (such as %USERNAME%, %APPDATA% …) and can also use :
%DESKTOP% : path to the current user's desktop
(more aliases will be added) |
| | destinationFolder="{Path}" | Idem |
| | searchPattern="{SearchPattern}" | Ie : "*.rdp", "*.lnk"… |
ConnectNetworkDrive | localDrive="{DriveLetter}" | Drive letter (in the format X: ) on which to mount the network share |
| | remotePath="{RemotePath}" | Path to the network share in UNC format (i.e. : \\server\share) |
Example : the Home configuration's Netlets element :
<Netlets>
<DefaultPrinter
printerName="MyInkjet" />
<CopyFiles
sourceFolder="%LOCALAPPDATA%\NetworkAwareAssistant\Home\CopyFiles\"
destinationFolder="%DESKTOP%"
searchPattern="*.rdp"
/>
<ConnectNetworkDrive
localDrive="J:"
remotePath="\\FamilyServer\Share" />
</Netlets>
A future version of NetworkAssistant will include a Control Panel application, but for this first release, you'll have to edit your settings manually.