Thursday, 29 July 2004
Controlling a dial-up connection via a web service
I just finished writing a simple client/server .Net application that allows windows PCs on a LAN to control the dial-up connection on a web server.
I'm currently using it at home on a small ad-hoc wireless network because the windows Internet Connection Sharing setting for 'dial on-demand' is very unreliable and it dials up when you don't want it to. This way you control when it connects and disconnects. Also, i was using terminal services to connect and disconnect which is way overkill!
I have put the source code and executables online for anyone to download, use modify etc. Download: RemoteDialer.zip (94 k). There is a readme file in there, but here are the instructions anyway which explain how it works and how to set it up.
How it works
The web server has methods for Dial() and Hangup(). They each call a batch file with Process.Start, which is configured to output the result of the operation to a text file. The batch files use the rasdial.exe tool to connect and disconnect the connection. The web service reads the text file before sending back the contents of it, to the client that requested the operation.
The desktop application for client PCs has a system tray icon, with a right-click menu to Start or Stop the connection.
There is also a web page to connect/disconnect, so you can allow non-windows users (who obviously couldn't run the desktop app) who are on your network to control the connection. To go to this page, just go to the address of the v.dir on the server.
To configure the web server:
- set up a new application pool which runs as Local Service
- copy the 'Web' folder to the web server
- make it a virtual directory
- set the AppPool for the v.dir to the appPool you just created
- Copy the 2 batch files in the 'Batch Files' folder to the server.
- It's easiest to put them in the c:\ root, otherwise you can
update the web.config application keys accordingly.
To configure the windows PCs:
- Locate the RemoteDialer.exe.config file in \WinClient\bin
- Adjust the http value key to match the server and v.dir name on the
- Copy the WinClient\Bin folder to each PC
- Run the .exe and you will see a new icon the system tray.
- Right-click the tray icon to start or stop the dial up connection
- The status of the operation is outputted to a pop up box.
Note: The reason for the new Application Pool is so that the web service
can interact with the system and write the output of operations
to text files.
If you have any comments or queries on it, or if there are bugs or problems, email me. tim@mackeyNO_SPAM_PLEASE.ie
Thursday, 29 July 2004 11:29:17 (GMT Daylight Time, UTC+01:00) .Net General