Danyfirex Posted April 30, 2014 Share Posted April 30, 2014 Try this: Local Const $UNLEN=256 Local Const $PWLEN = 256 Local Const $CNLEN =15 Local Const $DNLEN =$CNLEN $sTagRASCREDENTIALS = "dword dwSize;dword dwMask;wchar szUserName[" & $UNLEN+1 & "];wchar szPassword["& $PWLEN+1 & "];wchar szDomain[" & $DNLEN+1 &"]" Local $tTRASCREDENTIALS=DllStructCreate($sTagRASCREDENTIALS) DllStructSetData($tTRASCREDENTIALS,"dwSize",DllStructGetSize($tTRASCREDENTIALS)) DllStructSetData($tTRASCREDENTIALS,"dwMask",10) DllStructSetData($tTRASCREDENTIALS,"szUserName","gh1010") DllStructSetData($tTRASCREDENTIALS,"szPassword","aghh0") DllStructSetData($tTRASCREDENTIALS,"szDomain","") $phnbook ="C:\Users\Adnan\AppData\Roaming\Microsoft\Network\Connections\Pbk\rasphone.pbk" $entry ="hm" $msg = DllCall("Rasapi32.dll","DWORD","RasSetCredentialsW","wstr",$phnbook,"wstr",$entry,"ptr",DllStructGetPtr($tTRASCREDENTIALS),"BOOl",true) MsgBox(0,@error,$msg[0]) Saludos Starstar 1 Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
funkey Posted April 30, 2014 Share Posted April 30, 2014 You got this: ERROR_ACCESS_DENIED One of the following conditions occurred: The calling application attempted to set default credentials for a per-user connection. Default credentials can be set only for an all-user connection. The user does not have the correct privileges to set pre-shared keys or credentials for all users in case of all-user connectoids. Only administrators can complete these tasks. ERROR_ACCESS_DENIED = 5 ! Updated your code a bit: expandcollapse popupGlobal Const $UNLEN = 256 Global Const $PWLEN = 256 Global Const $CNLEN = 15 Global Const $DNLEN = $CNLEN Global Const $RASCM_UserName = 0x00000001 Global Const $RASCM_Password = 0x00000002 Global Const $RASCM_Domain = 0x00000004 Global Const $RASCM_DefaultCreds = 0x00000008 Global Const $RASCM_PreSharedKey = 0x00000010 Global Const $RASCM_ServerPreSharedKey = 0x00000020 Global Const $RASCM_DDMPreSharedKey = 0x00000040 Global Const $RASBASE = 600 Global Const $ERROR_CANNOT_OPEN_PHONEBOOK = $RASBASE + 21 Global Const $ERROR_CANNOT_FIND_PHONEBOOK_ENTRY = $RASBASE + 23 Global Const $sTagRASCREDENTIALS = "dword dwSize;dword dwMask;wchar szUserName[" & $UNLEN + 1 & "];wchar szPassword[" & $PWLEN + 1 & "];wchar szDomain[" & $DNLEN + 1 & "]" Global $tTRASCREDENTIALS = DllStructCreate($sTagRASCREDENTIALS) DllStructSetData($tTRASCREDENTIALS, "dwSize", DllStructGetSize($tTRASCREDENTIALS)) DllStructSetData($tTRASCREDENTIALS, "dwMask", BitOR($RASCM_DefaultCreds, $RASCM_Password)) DllStructSetData($tTRASCREDENTIALS, "szUserName", "gh1010") DllStructSetData($tTRASCREDENTIALS, "szPassword", "aghh0") DllStructSetData($tTRASCREDENTIALS, "szDomain", "") Global $phnbook = "C:\Users\Adnan\AppData\Roaming\Microsoft\Network\Connections\Pbk\rasphone.pbk" ;select phonebook $phnbook = 0 ; or use default phonebook Global $entry = "hm" Global $fClearCredentials = True Global $aRet If $phnbook Then $aRet = DllCall("Rasapi32.dll", "DWORD", "RasSetCredentialsW", "wstr", $phnbook, "wstr", $entry, "ptr", DllStructGetPtr($tTRASCREDENTIALS), "BOOL", $fClearCredentials) Else $aRet = DllCall("Rasapi32.dll", "DWORD", "RasSetCredentialsW", "ptr", 0, "wstr", $entry, "ptr", DllStructGetPtr($tTRASCREDENTIALS), "BOOL", $fClearCredentials) EndIf MsgBox(0, "", $aRet[0]) Starstar 1 Programming today is a race between software engineers striving tobuild bigger and better idiot-proof programs, and the Universetrying to produce bigger and better idiots.So far, the Universe is winning. Link to comment Share on other sites More sharing options...
Starstar Posted April 30, 2014 Author Share Posted April 30, 2014 Danyfirex Result is same 5 = bad parameter Life is like a coin. You can spend it Anyway as you wish and for your kind information. "you can spend it only once." Link to comment Share on other sites More sharing options...
Starstar Posted April 30, 2014 Author Share Posted April 30, 2014 funkey you are wright................i think i does not have the correct privileges to set pre-shared keys or credentials for all users in case of all-user connectoids. Only administrators can complete these tasks. Life is like a coin. You can spend it Anyway as you wish and for your kind information. "you can spend it only once." Link to comment Share on other sites More sharing options...
Danyfirex Posted April 30, 2014 Share Posted April 30, 2014 I don`t got error 5. Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
Starstar Posted April 30, 2014 Author Share Posted April 30, 2014 (edited) Topic Title is (@error) Sorry Error is 0 Retrun array is 5. look at image i uploaded........ Edited April 30, 2014 by Starstar Life is like a coin. You can spend it Anyway as you wish and for your kind information. "you can spend it only once." Link to comment Share on other sites More sharing options...
Solution Starstar Posted May 1, 2014 Author Solution Share Posted May 1, 2014 (edited) Thanks a lot of you all especially thanks to Funkey and Danyfirex. At the last Error bad parameter solved........Correct and healthy Code is......... Local Const $UNLEN=256 Local Const $PWLEN = 256 Local Const $CNLEN =15 Local Const $DNLEN =$CNLEN $sTagRASCREDENTIALS = "struct;dword dwSize;dword dwMask;wchar szUserName[" & $UNLEN+1 & "];wchar szPassword["& $PWLEN+1 & "];wchar szDomain[" & $DNLEN+1 &"];endstruct" Local $tTRASCREDENTIALS=DllStructCreate($sTagRASCREDENTIALS) DllStructSetData($tTRASCREDENTIALS,"dwSize",DllStructGetSize($tTRASCREDENTIALS)) DllStructSetData($tTRASCREDENTIALS,"dwMask",1+2) ; 1 for Username and 2 for Password +3 if you need to enter domain DllStructSetData($tTRASCREDENTIALS,"szUserName","test") DllStructSetData($tTRASCREDENTIALS,"szPassword","test") DllStructSetData($tTRASCREDENTIALS,"szDomain","") $phnbook =@AppDataDir & "Microsoft\Network\Connections\Pbk\rasphone.pbk" $entry ="hm" $msg = DllCall("Rasapi32.dll","DWORD","RasSetCredentialsW","wstr",$phnbook,"wstr",$entry,"struct*",$tTRASCREDENTIALS,"BOOl",FALSE) MsgBox(0,@error,$msg[0]) Edited May 1, 2014 by Starstar Danyfirex 1 Life is like a coin. You can spend it Anyway as you wish and for your kind information. "you can spend it only once." Link to comment Share on other sites More sharing options...
Danyfirex Posted May 1, 2014 Share Posted May 1, 2014 Hi. Do not pass false as string. just use False. Saludos Starstar 1 Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
Starstar Posted May 1, 2014 Author Share Posted May 1, 2014 Hi. Do not pass false as string. just use False. Saludos ok and thanks............. Life is like a coin. You can spend it Anyway as you wish and for your kind information. "you can spend it only once." Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now