[Previous] [Table of Contents] [Next]

# Calling a DUN Connection

You can use a WSH script to start a dial-up networking (DUN) connection. WSH doesn't provide an object for direct access, so you must use a trick and call the DUN connection by using the Run method of the Shell object. You again have to execute RunDll32.exe by using the following Windows 95 or Windows 98 command:

    %WINDIR%\RunDll32.exe rnaui.dll,RnaDial name

%WINDIR% is a placeholder for the Windows folder. The placeholder name stands for the requested entry in your DUN folder (CS3 Connection, for example). You can check the command by using the Run dialog box. (Choose Run from the Start menu.) The VBScript program shown in Listing 14-21 connects to DUN by using a CompuServe connection.

Listing 14-21 DUN.vbs

    '************************************************
    ' File:    DUN.vbs (WSH sample in VBScript)
    ' Author:  (c) G. Born
    '
    ' Invoking dial-up networking (DUN)
    '************************************************
    Option Explicit

    Dim wsh

    Set wsh = WScript.CreateObject("WScript.Shell")

    wsh.Run "%WINDIR%\RunDll32.exe rnaui.dll,RnaDial CS3 Connection", _
            1, True

    WScript.Echo "Ready"

    '*** End

> IMPORTANT

> If you use DUN in Windows NT, the command to invoke the connection is a bit different. You create a shortcut to the DUN entry and then use the command obj.Run "Rasphone.exe -t xxx", 1, True, where xxx is the name of the shortcut file to the DUN entry.

For more control over DUN or the Dial-Up Networking Monitor in Windows NT (for example, to be able to hang up the phone), you can use ActiveX controls that provide objects and methods for accessing Remote Access Service (RAS) or Winsock/TCP/IP. Table 14-3 lists some Web sites from which you can download such ActiveX controls and samples.

Table 14-3 Web Sites with ActiveX Controls for Accessing RAS and DUN

Web Site | Description
--- | ---
http://www.catalyst.com | Catalyst Development Corporation site. Offers SocketTools, an ActiveX control for WindowsSockets programming and information about TCP/IP programming.
http://www.voidpointer.com | Voidpointer, LLC site. Offers Script Driven Internet (SDI32), a tool for automating Internet-related tasks (such as FTP and e-mail) from a script.
http://cwashington.netreach.net | The download section of C. Washington's site. Contains ActiveX controls and samples for accessing RAS and DUN.
http://factory.glazier.co.nz | Factory Software Components site. Contains helpful ActiveX controls.
http://www.mvps.org/ccrp/ | Common Controls Replacement Project site.