Seahorse 0 Posted May 19, 2010 I am receieving the following error with my script after converting to au3. Error parsing function call My intension is to convert into EXE but receive the error. The script works ok when executed as vbs with its original coding but after being converted it no longer works. I have uploaded the file for your perusal and would greatly appreciate any help you can provide. My experience with scripting is very basic but I have a number of scripts in use to make my life easier which I would like to share with colleagues as EXE. I am currently attempting to better my scripting skills and would like to begin using AutoIt as an alternative to vbs. Thank you Kind Regards Seahorsescript.au3 Share this post Link to post Share on other sites
water 2,387 Posted May 19, 2010 Something like this? $WshShell = ObjCreate("WScript.Shell") Global $nAble = 0 $aGateway = StringSplit(DefaultGateway(), ".") Select Case $aGateway[0] = "172" $nAble = 1 Case $aGateway[0] = "192" $nAble = 0 Case Else $nAble = 0 EndSelect $WshShell.RegWrite("HKCU\software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyEnable", $nAble, "REG_DWORD") $WshShell.RegWrite("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyEnable", $nAble, "REG_DWORD") Func DefaultGateway() Local $Return = "", $oDG, $oDGs, $WMI $WMI = ObjGet("winmgmts:\\.\root\cimv2") $oDGs = $WMI.ExecQuery("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=" & True) For $oDG In $oDGs If $oDG.defaultIPGateway(0) <> "0.0.0.0" Then $Return = $oDG.DefaultIPGateway(0) ExitLoop EndIf Next Return $Return EndFunc ;==>DefaultGateway My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - WikiOutlookEX (NEW 2020-12-15 - Version 1.6.3.1) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2020-06-27 - Version 1.3.2.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - WikiTask Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - WikiTutorials:ADO - Wiki, WebDriver - Wiki Share this post Link to post Share on other sites
Seahorse 0 Posted May 19, 2010 Thank you I'll give it a go and report back. Share this post Link to post Share on other sites
Seahorse 0 Posted May 20, 2010 Thank you It does appear to be working without error. Unfortunately it is performing the oposite function to what I'd like it to. Case $aGateway[0] = "172" $nAble = 1 Case $aGateway[0] = "192" $nAble = 0 Case Else $nAble = 0 To me this looks fine but I'm sure I'm missing something. I have changed it to remove the "192" and left Case Else to disable instead. This has made no difference. I'm wondering whether the script is skipping the detection of the default gateway and simply blanking the registry DWORD. Could the ordering be out slightly? Thank you Share this post Link to post Share on other sites
water 2,387 Posted May 20, 2010 Insert some ConsoleWrite statements so you can see what's going on: $WshShell = ObjCreate("WScript.Shell") Global $nAble = 0 $Result = DefaultGateway() $aGateway = StringSplit($Result, ".") ConsoleWrite("Gateway: " & $Result & @CRLF) ConsoleWrite("Gateway[0]: " & $aGateway[0] & @CRLF) Select Case $aGateway[0] = "172" $nAble = 1 Case $aGateway[0] = "192" $nAble = 0 Case Else $nAble = 0 EndSelect ConsoleWrite("$nAble: " & $nAble & @CRLF) $WshShell.RegWrite("HKCU\software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyEnable", $nAble, "REG_DWORD") $WshShell.RegWrite("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyEnable", $nAble, "REG_DWORD") Func DefaultGateway() Local $Return = "", $oDG, $oDGs, $WMI $WMI = ObjGet("winmgmts:\\.\root\cimv2") $oDGs = $WMI.ExecQuery("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=" & True) For $oDG In $oDGs If $oDG.defaultIPGateway(0) <> "0.0.0.0" Then $Return = $oDG.DefaultIPGateway(0) ExitLoop EndIf Next Return $Return EndFunc ;==>DefaultGateway My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - WikiOutlookEX (NEW 2020-12-15 - Version 1.6.3.1) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2020-06-27 - Version 1.3.2.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - WikiTask Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - WikiTutorials:ADO - Wiki, WebDriver - Wiki Share this post Link to post Share on other sites