WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

RAS

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Set Pre-Shared Key for VPN


;UNDEBUGGED CODE
AddExtender("wwras34i.dll")
YourPreSharedKey = "?????"
raslist = RasItemize() 
entryname = AskItemlist("Choose a RAS entry",raslist,@TAB,@UNSORTED,@SINGLE)

;If the dwMask member specifies that a pre-shared key should be used for the credentials, 
;the szPassword member contains the pre-shared key.
RASCM_PreSharedKey = 16   ;Windows 2000/NT:  This flag is unsupported.
dwMask = RASCM_PreSharedKey
size = 540
RASCREDENTIALS = BinaryAlloc(size)
BinaryPoke4(RASCREDENTIALS, 0, size) ;set size of structure
BinaryPoke4(RASCREDENTIALS, 4, dwMask)
BinaryPokeStr(RASCREDENTIALS, 8, "")
BinaryPokeStr(RASCREDENTIALS, 265, YourPreSharedKey)
BinaryPokeStr(RASCREDENTIALS, 522, "")
BinaryEodSet( RASCREDENTIALS, size)

dllfilename = StrCat(Dirwindows(1), "Rasapi32.dll")
ret = DllCall( dllfilename, long:"RasSetCredentialsA" , lpnull, lpstr:entryname, lpbinary:RASCREDENTIALS, long:0)
if ret != 0
   Message("RasSetCredentials Error",ret)
   BinaryFree(RASCREDENTIALS)
   exit
endif

BinaryFree(RASCREDENTIALS)
exit
 

Article ID:   W16856
File Created: 2017:07:28:12:58:41
Last Updated: 2007:07:03:13:26:36