For developers

Here you can find few examples how to programatically control the traffic using NetLimiter 2 API. More information will be available soon on our forums.

  1. Install NetLimiter 2 (You don't need to run the GUI application)
  2. Allow NetLimiter API - In NetLimiter configuration file set the 'AllowAPI' parameter to 'true'. The conf. file is usually located at 'C:\Documents and Settings\All Users\Application Data\Locktime\NetLimiter\2\nl-settings.xml'. Don't forget to stop the NetLimiter service prior to change this value.
  3. Run following scripts - save it to '.js' file and execute it.
The examples are written in JavaScript but you can easily convert it to any other language like VBScript or C++.

Example 1: How to set limit

The following code sample shows how to switch on download limit for Internet Explorer. The size of the limit is set to 1024 Bytes.

JavaScript: How to switch on the limit
	var vc = new ActiveXObject("NetLimiter.VirtualClient");

	vc.Connect("localhost"/*addr*/, ""/*port or pipe*/);

	var newRuleId = vc.SetRule(
		"C:\\Program Files\\Internet Explorer\\iexplore.exe",
		"limit",// rule type
		"in", // for download (incoming)
		"Internet",// zone
		true, // rule is enabled
		"1024", // 1024 Bytes
		"");
	

And the following code sample switches off the limit.

JavaScript: How to switch off the limit
	var vc = new ActiveXObject("NetLimiter.VirtualClient");

	vc.Connect("localhost"/*addr*/, ""/*port or pipe*/);

	var newRuleId = vc.SetRule(
		"C:\\Program Files\\Internet Explorer\\iexplore.exe",
		"limit",// rule type
		"in", // for download (incoming)
		"Internet",// zone
		false, // rule is disabled
		"1024", // 1024 Bytes
		"");
	

Example 2: Firewall rules

The following sample shows how to deny Internet Explorer to connect to the Internet zone.

JavaScript: How to deny outgoing connections
	var vc = new ActiveXObject("NetLimiter.VirtualClient");

	vc.Connect("localhost"/*addr*/, ""/*port or pipe*/);

	var newRuleId = vc.SetRule(
		"C:\\Program Files\\Internet Explorer\\iexplore.exe",
		"fw",// rule type
		"out", // outgoing
		"Internet",// zone
		true, // rule is enabled
		"deny", // deny
		"");
	

The following sample shows how to allow Internet Explorer to connect to the Internet zone.

JavaScript: How to allow outgoing connections
	var vc = new ActiveXObject("NetLimiter.VirtualClient");

	vc.Connect("localhost"/*addr*/, ""/*port or pipe*/);

	var newRuleId = vc.SetRule(
		"C:\\Program Files\\Internet Explorer\\iexplore.exe",
		"fw",// rule type
		"out", // outgoing
		"Internet",// zone
		true, // rule is enabled
		"allow", // allow
		"");