Networking

Remote Desktop via VPN

Posted in Networking, Software on June 17th, 2010 by Mr. Bungle – Be the first to comment

For many programmers and IT professionals, remote access via VPN to machines in their corporate network is a routine activity. This activity usually involves launching a VPN client (e.g. ShrewSoft VPN Client), entering a password, waiting for the VPN to be connected, then launching the remote desktop client. I have written a small executable to help automate that process, called DirectToDesktop.

The program launches your VPN client with the specified arguments and then starts a remote desktop session to a specified computer as soon as that machine can be pinged.

Usage

DirectToDesktop.exe <pathToVpnClient> <vpnClientArgs> <hostName> [pathToLookAlive]

<pathToVpnClient> – E.g. “C:\Program Files\ShrewSoft\VPN Client\ipsecc.exe”
<vpnClientArgs> – Args to pass to the VPN client.  E.g. “-r \”Your Company.pcf\”"
<hostName> – The name/IP of the computer inside the VPN to remote desktop to.
[pathToLookAlive] – (optional) Install Look Alive to view connectivity status of the remote computer in the system tray.  E.g. “C:\Program Files (x86)\Zorn Software\Look Alive v1.24\LookAlive.exe”

Note: I’ve only tested the program with ShrewSoft VPN Client, but in theory it should work with any VPN client that accepts command line arguments.

Installation
Just save DirectToDesktop.exe to any location on your hard disk, and add a shortcut to it using the above command line arguments. Run the executable without passing any arguments to view a help/about window.

Windows 7 disconnected network drives

Posted in Networking, Software, Windows 7 on March 7th, 2010 by Mr. Bungle – 15 Comments

Mapped network drives have always been a buggy area in Windows, probably at least in part because they are still linked to a DOS namespace. From MSDN:

On Windows Server 2003 and Windows XP, the WNet functions create and delete network drive letters in the MS-DOS device namespace associated with a logon session…

Whatever the reason, it is commonly reported that mapped network drives appear as ‘disconnected’ in Windows Explorer (or ‘unavailable’ via net use), and that programs that attempt to use these drive mappings will fail until the user physically clicks on the drive letter in Windows Explorer. Only this user-initiated action will restore the connection and allow other programs to successfully read from the drive letter.

The dreaded disconnected network drive balloon.

This is a BIG problem!

I initially thought that the mapping of the network drives was being done before some required services had started (such as the Workstation and Server services), so I wrote a program to run on startup that attempted to map a drive and logged all the currently running services if it failed. It would keep trying to map a drive until it succeeded. I hoped it would show me which services needed to be running in order to map a drive, after which I would write a program to wait for those services before attempting to map anything. But, much to my amazement, I found that when the initial drive mapping failed and a subsequent attempt succeeded, the set of running services had not changed! So I could only conclude that there was another element in the equation. After thinking about this for a while, and reading this post, which indicates that Microsoft is apparently trying to address this, I decided ‘stuff it’, I’ll just write something that I know will work and is simple.

So I’ve written a small executable called MapDrive.exe to ‘work around’ this problem, described on the following dialog:

About MapDrive

Now as you may know since Vista, there is the concept of a split user token, and mapped network drives apply to only one token, so if you map drives as a standard user and then run an elevated process, those network drives are not available to the elevated process. This behaviour is documented by Microsoft, however the solution they offer is both unsupported and unsafe. Other solutions have been proposed here. If you don’t wish to use any of these solutions, you can do this:

1. Run MapDrive.exe as a shortcut from your Startup folder. This will map drives for the standard user token.
2. Run MapDrive.exe as a local group policy logon script using gpedit.msc. This will map drives for the administrator token.

Note: After using this program, you may still see the above balloon popup, simply click the spanner icon, and select ‘Hide icon and notifications’ for ‘Windows Explorer’.

Download the utility for free here.

UPDATE: A few people have asked how to use this program. As stated above, there are two ways, depending on whether you need drives mapped for standard users or admins. If you don’t know what you need, you probably just need to do this for standard users. Here are the steps for both:

1. Copy MapDrive.exe to somewhere on your local hard drive.

Standard Users:
2. Right-click MapDrive.exe and choose ‘Create Shortcut’. This will create a file called ‘MapDrive.exe – Shortcut’ next to MapDrive.exe. Now go Start->All Programs, right-click the ‘Startup’ folder and choose ‘Open’. Now copy the shortcut file you made before to this folder. Now right-click the shortcut file and choose ‘Properties’. Add the drive letter and network share as argument to the end of the ‘Target’ field e.g. “C:\Users\joeblogs\Documents\MapDrive.exe s: \\server\share 20″. You are done, next time you reboot, your s: should be mapped successfully for standard users.

Admin Users:
3. Press Win+R, type gpedit.msc, go User Configuration->Windows Settings->Scripts. Double-click Logon, click ‘Add’ and enter script name (no quotes): “C:\Users\joeblogs\Documents\MapDrive.exe” and script parameters (no quotes): “s: \\server\share 20″, ok, ok, done. You are done, next time you reboot, your s: should be mapped successfully for admin users (i.e. elevated programs).

Network CHMs = Pain courtesy of IE

Posted in Networking, Software, Windows 7 on February 19th, 2010 by Mr. Bungle – Be the first to comment

Despite being around since 1997, CHM files still remain a popular format for program help / documentation as well as ebooks. But opening them from a network drive was outlawed in 2005 after Microsoft released this security update. There was a registry hack workaround to enable it again, however this no longer works in Windows 7. The solution accepted on this thread involves two steps:

1. Add this registry key:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\HTMLHelp\1.x\ItssRestrictions]
"MaxAllowedZone"=dword:00000001

2. In Internet Explorer->Tools->Internet Options and add your network drive into the safe/trusted zones.

Just the thought of firing up IE gives me the security-shivers and I really don’t want to be messing about with ‘trusted zones’ – I don’t trust IE to do anything. I’m surprised the US government hasn’t yet advised its citizens against using IE, like Australia, France and Germany have.

Of course the whole reason this has anything to do with IE is because the built in HH.exe that is the default Html Help viewer on Windows uses IE as the web browser engine to display and navigate the HTML files inside the CHM. So we could avoid this whole problem if there was a CHM viewer that doesn’t use IE at all. Now to the motivation for this post:

Enter xCHM – this is an open-source project that predominantly provides support for viewing CHM files on non-windows platforms, however it has been ported to Windows, so you can kiss HH.exe goodbye, and open your CHMs from any network location without having to hack your registry or mess with IE zones!!

Download the Windows port of xCHM (look under xCHM for Win32).

Internet over copper sucks

Posted in Networking, Software on November 7th, 2009 by Mr. Bungle – 2 Comments

I am subscribed to the fastest available ADSL 2+ (24Mbps) connection here in Sydney, and my connection at three different houses I’ve lived in has always been unreliable.  Currently where I’m living, the connection actually goes down whenever it starts raining!  :?   It also frequently goes down just at random, when it’s not raining.  P2P seems to worsen the situation (not surprisingly), but usenet is superior anyway, so that’s not a problem anymore.  Granted, I am pretty far from the exchange (~4km), hopefully copper will be replaced with optic fibre in the next decade.

So a while back I wrote a small utility that shows an icon in the system tray reflecting whether you can contact (via ping) a remote host (google, or your ISP’s DNS server, for example).

Online icon: lookalive-up

Offline icon: lookalive-down

Clicking the icon shows your the history of ping times:

Look Alive

It can be run on startup, passing the name or IP of the remote host as an argument.  For example:

"lookalive.exe www.google.com"

You can also specify the period (in seconds) between pings (default is 1 second), so to ping www.google.com every 5 seconds:

"lookalive.exe www.google.com 5"

If you have multiple hosts you wish to ping, you can run the application multiple times and a spearate icon in the system tray is displayed for each host. To distinguish between them, you can pass a colour:

"lookalive.exe www.google.com 5 blue"

Additional arguments allow calling of an external application and/or showing a balloon notification whenever the state changes and customisation of the system tray icon.

Download the utility for free as an installer or as a standalone EXE.