#include <_GDIPlus_LoadingSpinner--MR.au3> Local $PHK = @ScriptDir & "\VPN.pbk" Local $EN = "VPN1" Local $USR = "USR1" Local $PSW = "PSW1" _LoadingScreen_Spinner(1) RasDial_API($EN, $USR, $PSW, $PHK) ;~ RasDial_EXE($EN, $USR, $PSW, $PHK) _LoadingScreen_Spinner(0) Sleep(2000) RasDial_DC() Func RasDial_API($EntryName, $UserName, $Password, $PhonebooK) #Region ;Options Local Const $RAS_MaxAreaCode = 10 Local Const $RAS_MaxPhoneNumber = 128 Local Const $RAS_MaxDeviceType = 16 Local Const $RAS_MaxDeviceName = 128 Local Const $RAS_MaxPadType = 32 Local Const $RAS_MaxX25Address = 200 Local Const $RAS_MaxCallbackNumber = 128 ;$RAS_MaxPhoneNumber Local Const $RAS_MaxFacilities = $RAS_MaxX25Address Local Const $RAS_MaxUserData = $RAS_MaxFacilities Local Const $RAS_MaxDnsSuffix = 256 Local Const $RAS_MaxEntryName = 256 Local Const $WM_RASDIALEVENT = 0xCCCD Local Const $RASCS_DONE = 0x2000 Local Const $WAIT_OBJECT_0 = 0 Local $hConection = 0 Local Const $DNLEN =15 #cs typedef struct _RASDIALPARAMS { DWORD dwSize; TCHAR szEntryName[RAS_MaxEntryName + 1]; TCHAR szPhoneNumber[RAS_MaxPhoneNumber + 1]; TCHAR szCallbackNumber[RAS_MaxCallbackNumber + 1]; TCHAR szUserName[UNLEN + 1]; TCHAR szPassword[PWLEN + 1]; TCHAR szDomain[DNLEN + 1]; DWORD dwSubEntry; ULONG_PTR dwCallbackId; DWORD dwIfIndex; } RASDIALPARAMS, *PRASDIALPARAMS; #ce Local Const $tagRASDIALPARAMS = "dword dwSize;" & _ "wchar szEntryName["& $RAS_MaxEntryName +1 &"];" & _ "wchar szPhoneNumber["& $RAS_MaxPhoneNumber +1 &"];" & _ "wchar szCallbackNumber["& $RAS_MaxCallbackNumber +1 & "];" & _ "wchar szUserName[" & $RAS_MaxDnsSuffix +1 & "];" & _ "wchar szPassword["& $RAS_MaxDnsSuffix + 1 & "];" & _ "wchar szDomain["&$DNLEN +1 &"];" & _ "dword dwSubEntry;" & _ "ULONG_PTR dwCallbackId;" & _ "dword dwIfIndex" #EndRegion ;Options Local $tRASDIALPARAMS = DllStructCreate($tagRASDIALPARAMS) $tRASDIALPARAMS.dwSize = DllStructGetSize($tRASDIALPARAMS) DllStructSetData($tRASDIALPARAMS, "szPhoneNumber", "") DllStructSetData($tRASDIALPARAMS, "szCallbackNumber", "") DllStructSetData($tRASDIALPARAMS, "szDomain", "") DllStructSetData($tRASDIALPARAMS, "szEntryName", $EntryName) DllStructSetData($tRASDIALPARAMS, "szUserName", $UserName) DllStructSetData($tRASDIALPARAMS, "szPassword", $Password) Local $iRet = DllCall("Rasapi32.dll", "dword", "RasDialW", "ptr", 0,"wstr", $PhonebooK, "ptr", DllStructGetPtr($tRASDIALPARAMS), "dword", 0, "ptr", Null, "handle*", NULL) ConsoleWrite("Rasdial msg = " & $iRet[0] & @CRLF) If $iRet[0] Then Local $Ret = DllCall("Rasapi32.dll", "dword", "RasGetErrorStringW", "uint", $iRet[0], "wstr", NULL, "dword", 256) ConsoleWrite( $Ret[2] & @CRLF) $hConection = $iRet[6] Else ConsoleWrite("Rasdial OK" & @CRLF) $hConection = $iRet[6] EndIf EndFunc Func RasDial_EXE($EntryName, $UserName, $Password, $PhonebooK) $lastError = "" $cmdline = "rasdial " & $EntryName & " " & $UserName & " " & $Password & ' /PHONEBOOK:"' & $PhonebooK & '"' $pid = Run(@ComSpec & " /C " & $cmdline, "", @SW_HIDE, $STDOUT_CHILD) While ProcessExists($pid) $sSTD = StdoutRead($pid) $lastError &= $sSTD ConsoleWrite (@CRLF & " --> "& $sSTD) $sSTD = "" WEnd ConsoleWrite("Rasdial Msg = " & $lastError & @CRLF) Return $lastError EndFunc Func RasDial_DC() $lastError = "" $cmdline = "rasdial /d" $pid = RunWait(@ComSpec & " /C " & $cmdline, "", @SW_HIDE) EndFunc