How to cleanly and automatically disconnect all VPN connections to Windows 2000, XP, 2003, 2008, Vista and 2008 R2 (for example on server shutdown): RRAS VPN Shutdown Tool

System Requirements:

  • Windows 2000
  • Windows XP
  • Windows Server 2003, 2003 R2
  • Windows Vista
  • Windows 7
  • Windows Server 2008, 2008 R2

The Problem:

Every now and then when a server gets rebooted you see slight bug appear in Windows Vista, 7, 2008 and 2008 R2 is it is VPN’d into said rebooting server. RASDial (the VPN client on said OS’s) thinks that the connection is still established. If you try and disconnect it (or once it realises) the connection status will change to “disconnecting” and it will stay like that.

In this state you can not connect, disconnect or delete the connection and the only way to fix it is to log off or restart.

If you disconnect all connections from the server before you do it i.e. cleanly, it doesn’t happen.

More Info

This is a particular problem if you have Task Manager, Scheduler or AT dialling VPN connections for you, it is less prevalent if the user dials the connection.

The Fix

Current Version:





Source Availability:


In the absence of there being an existing command line utility on the server to do this for you, I created the server utility equivalent of rasdial.exe /disconnect. When run, this utility will find any open inbound VPN connections and kill them off; cleanly.

The suggestion here is that you run it as part of your RRAS servers shutdown script so that all connections are knocked off before the RRAS service stops.

This is a two pronged utility.

It is compatible with “Microsoft Routing and Remote Access Server” on:

  • Windows 2000 Server
  • Windows Server 2003 (R2)
  • Windows Server 2008
  • Windows Server 2008 R2

As a bonus it also works with the “Accept incoming connections” dial-in system on:

  • Windows 2000 Professional
  • Windows 2000 Server
  • Windows XP
  • Windows Server 2003, R2
  • Windows Vista
  • Windows Server 2008
  • Windows 7
  • Windows Server 2008 R2


Note: Please be aware that the utility will also knock off any dial-up connections that happen to be connecting through the server; as it was designed to be run during shutdown I haven’t discriminated between VPN and dial-up connections.

It is written in C++ and compiled against MSVCRT6 so should work right out of the box on all platforms — assuming Windows 2000 is patched to SP4.


This is code written by me, I offer no warranties (expressed or implied) on its use. Test before you put it into production.

If it is useful to you please consider donating!


Download: RRAS VPN Shutdown Tool (47 KB)