Cisco VPN Client and Windows 8

I upgraded to Windows 8 (from Windows 7) several months ago and one of the things that stopped working is the Cisco VPN client. As of this writing, the most recent version is 5.0.07.0440. This build installs properly but fails when you try to establish a connection. I found a solution wanted to share it since it’s been working great for over 3 months without an issue.

1) Close the VPN client, make sure it’s not running.
2) Open up regedit and navigate to:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\CVirtA
3) Make a backup of this, just in case. Right click the CVirtA key in the explorer and export the settings for this key as a reg file.
4) Edit the DisplayName value, stripping off the characters until “%;”. For example…
For x64 you can change the value from something like “@oem8.inf,%CVirtA_Desc%;Cisco Systems VPN Adapter for 64-bit Windows” to “Cisco Systems VPN Adapter for 64-bit Windows”. For x86, you’ll change the value from something like “@oem8.inf,%CVirtA_Desc%;Cisco Systems VPN Adapter” to “Cisco Systems VPN Adapter”.
5) Open the VPN client and try connecting again
6) If this doesn’t work, restore your original settings by double clicking the reg file you saved in step 3.

Special thanks to Raman-MSFT from this MSDN post for this solution!

Executing commands when starting cmd.exe

If you use the command prompt in Windows often, you might find it useful to setup a script to fire when it’s opened. Something similar to a bashrc file getting executed in Linux when you login. You can setup something like this using the registry.

Crack open regedit and navigate to:
HKEY_CURRENT_USER\Software\Microsoft\Command Processor

Once here, you can add a value called AutoRun and provide the path to the script to run. For example, if you want to run C:\myScript.bat when the prompt is open, you’d create a new string value called AutoRun with a value of C:\myScript.bat

Click here for more information about cmd.exe

Handling NIC information on Windows

If you need to programmatically get info about the NIC, you can find it in the registry:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}

You can enumerate through all of the sub-keys; they’re labeled as 0000, 0001, 0002, etc. If you’re on Windows Vista / Server 2008, be sure to catch exceptions because there is a sub-key called Properties that you will get an access violation on.

For example, in my Shuttle SG33G5, I have my primary NIC under a sub-key called 0004. I can tell it’s my primary NIC because of the DriverDesc value. From this key, you can set duplex, buffer sizes, and other NIC driver settings.

Just as an example, lets say you want to set your NIC to be 100Mbps full duplex. Before you make an automated solution, you can see the values passed to the NIC driver in the sub-key called NDI under the sub-key Params. In my case, I would need to open this key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}\0004\Ndi\Params\*SpeedDuplex

There is a value here called default and it’s set to 0. Looking at the sub-key called enum, there are some values I could use:
0 = Auto Negotiation
1 = 10 Mbps Half Duplex
2 = 10 Mbps Full Duplex
3 = 100 Mbps Half Duplex
4 = 100 Mbps Full Duplex

So when it’s time for automating this, my code would:
1) Open this key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}
2) Go through each sub-key (0000,0001,0002…), until it finds a value DriverDesc called “Generic Marvell Yukon Chipset based Ethernet Controller”.
3) I know for this card, the value 4 is 100Mbps. So I can set the value data for “*SpeedDuplex” to 4. The full path to this registry value is
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}\0004\*SpeedDuplex
4) After making the change you can restart your network interface by making a shell execute call to netsh.exe
netsh interface set interface "Local Area Connection" DISABLED
netsh interface set interface "Local Area Connection" ENABLED

This article is basically documentation of some code my friend Daymion wrote. You can probably achieve the same result with WMI, but it’s a lot nastier to do that in C or C++.

Executing a program at startup on Windows

Run and RunOnce registry keys cause programs to run each time that a user logs on. The data value for a key is a command line. Register programs to run by adding entries of the form description-string=commandline. You can write multiple entries under a key. If more than one program is registered under any particular key, the order in which those programs run is indeterminate.

The Windows registry includes the following four keys:
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce

By default, the value of a RunOnce key is deleted before the command line is run. You can prefix a RunOnce value name with an exclamation point (!) to defer deletion of the value until after the command runs. Without the exclamation point prefix, if the RunOnce operation fails the associated program will not be asked to run the next time you start the computer.

By default, these keys are ignored when the computer is started in Safe Mode. The value name of RunOnce keys can be prefixed with an asterisk (*) to force the program to run even in Safe mode.

For more information, check out these articles:
http://support.microsoft.com/kb/179365
http://msdn.microsoft.com/en-us/library/aa376977(VS.85).aspx