au3scr Posted April 25, 2008 Share Posted April 25, 2008 (edited) In my computer compiled script works but if i try execute it in other computer I get errors Autoit error Line: -1 Error: Subscript used with non-array variable here is script expandcollapse popupOpt("OnExitFunc", "endscript") HotKeySet("!{f4}", "noexit") AutoItSetOption("GUICloseOnESC", 0) #include <GUIConstants.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> #include <File.au3> #include <String.au3> #include <GuiEdit.au3> #include <Process.au3> $read = FileReadLine(@ScriptDir & "\path", 1) $decrypted = _StringEncrypt(0, $read, "keerulinesalas6na", 1) $configfilepath = $decrypted $fileget = FileExists($configfilepath) If $fileget = 0 Then Defaults() EndIf $def = FileReadLine($configfilepath, 1) If $def = "Rebindall" Then Defaults() EndIf Global $pass = FileReadLine($configfilepath, 1) Global $pass2 = FileReadLine($configfilepath, 22) Global $background = FileReadLine($configfilepath, 25) Dim $sourceFolder = @DesktopDir Global $Array = _FileListToArray($sourceFolder, "*.lnk", 1) StringReplace($Array, ".exe", "") Global $avMenuItems[$Array[0] + 1] #region ### START Koda GUI section ### Form= $Form1 = GUICreate("FluxBox", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP) $avMenuItems[0] = GUICtrlCreateMenu("Programs") For $i = 1 To $Array[0] $avMenuItems[$i] = GUICtrlCreateMenuItem(StringReplace($Array[$i], ".lnk", ""), $avMenuItems[0]) Next $taskbarbtn = GUICtrlCreateButton("<", @DesktopWidth - 10, @DesktopHeight / 2, 10, 30) GUICtrlSetColor(-1, 0x0000ff) GUICtrlSetFont(-1, 16, 500, 1, "terminal") GUICtrlSetBkColor(-1, 0xFFFFE1) GUISetBkColor(0x3A6EA5) $MenuItem1 = GUICtrlCreateMenu("Exit") $MenuItem11 = GUICtrlCreateMenuItem("exit", $MenuItem1) $MenuItem12 = GUICtrlCreateMenuItem("Shutdown", $MenuItem1) $MenuItem13 = GUICtrlCreateMenuItem("Restart", $MenuItem1) $MenuItem14 = GUICtrlCreateMenuItem("Log Off", $MenuItem1) $MenuItem2 = GUICtrlCreateMenu("Help") $MenuItem20 = GUICtrlCreateMenuItem("About", $MenuItem2) $MenuItem3 = GUICtrlCreateMenu("Administration") $MenuItem30 = GUICtrlCreateMenuItem("Wallpaper", $MenuItem3) $MenuItem31 = GUICtrlCreateMenuItem("Taskmanager", $MenuItem3) $MenuItem32 = GUICtrlCreateMenuItem("Run", $MenuItem3) $MenuItem33 = GUICtrlCreateMenuItem("CMD", $MenuItem3) $MenuItem34 = GUICtrlCreateMenuItem("Control", $MenuItem3) $MenuItem35 = GUICtrlCreateMenuItem("Configuration editor", $MenuItem3) $MenuItem36 = GUICtrlCreateMenuItem("Plugins management", $MenuItem3) Global $Pic = GUICtrlCreatePic($background, 0, 0, @DesktopWidth, @DesktopHeight - 15, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS)) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlCreateLabel(@YEAR & ":" & @MON & ":" & @MDAY, @DesktopWidth - 150, @DesktopHeight - 55, 150, 15) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) $time = GUICtrlCreateLabel(@HOUR & ":" & @MIN & ":" & @SEC, @DesktopWidth - 150, @DesktopHeight - 40, 150, 15) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) AdlibEnable("Time", 1000) ;~ noexp() ;~ nodm() GUISetState(@SW_SHOW) #endregion ### START Koda GUI section ### Form= While 1 $nMsg = GUIGetMsg() For $n = 1 To UBound($avMenuItems) - 1 If $nMsg = $avMenuItems[$n] Then ShellExecute($sourceFolder & "\" & $Array[$n]) ExitLoop EndIf Next Switch $nMsg ;~ Case $GUI_EVENT_CLOSE ;~ Exit Case $MenuItem11 endscript() ;~ Exit Case $MenuItem12 Shutdown(1) Case $MenuItem13 Shutdown(2) Case $MenuItem14 Shutdown(0) Case $MenuItem20 $aboutmsg = FileRead (@ScriptDir&"\about.txt") MsgBox(64,"About - Current version 1.10",$aboutmsg) Case $MenuItem30 wallpaperset() Case $MenuItem31 taskman() Case $MenuItem32 runother() Case $MenuItem33 cmd() Case $MenuItem34 control() Case $MenuItem35 conf () Case $MenuItem36 plugin () Case $taskbarbtn $load = FileReadLine($configfilepath, 24) Run($load) EndSwitch WEnd Func endscript() $Password = InputBox("Enter Password", "You must enter password to close this window", "", "*") If $Password = $pass Then ProcessClose("sticky.exe") ProcessClose("taskmgr.exe") ProcessClose("DisableTaskManager.exe") Run("explorer") ProcessClose("flux.exe") Exit Else EndIf EndFunc ;==>endscript Func noexp() $noexp = FileReadLine($configfilepath, 3) If $noexp = "Yes" Then $pid = ProcessExists("explorer.exe") $handle = _WinAPI_OpenProcess(0x1, 0, $pid) DllCall("kernel32.dll", "int", "TerminateProcess", "int", $handle, "int", 1) EndIf EndFunc ;==>noexp Func nodm() $noexp = FileReadLine($configfilepath, 4) If $noexp = "Yes" Then Run("DisableTaskManager.exe") EndIf EndFunc ;==>nodm Func wallpaperset() $wallpaperallowordeny = FileReadLine($configfilepath, 17) If $wallpaperallowordeny = "Wallpapers=YES" Then $path = FileOpenDialog("Select wallpaper:", "", "(*.*)") If Not @error Then GUICtrlSetImage($Pic, $path) If $wallpaperallowordeny = "Wallpapers=NO" Then MsgBox(64, "Not allowed", "You do not have permission") EndIf EndIf EndFunc ;==>wallpaperset Func taskman() $Password = InputBox("Enter Password", "You must enter password to close this window", "", "*") If $Password = $pass2 Then ProcessClose("DisableTaskManager.exe") ProcessClose("taskmgr.exe") Run(@SystemDir & "\taskmgr.exe") Else EndIf EndFunc ;==>taskman Func runother() $Password = InputBox("Enter Password", "You must enter password to close this window", "", "*") If $Password = $pass2 Then $load = FileReadLine($configfilepath, 23) Run($load) Else EndIf EndFunc ;==>runother Func cmd() $Password = InputBox("Enter Password", "You must enter password to close this window", "", "*") If $Password = $pass2 Then Run(@SystemDir & "\cmd.exe") Else EndIf EndFunc ;==>cmd Func control() $Password = InputBox("Enter Password", "You must enter password to close this window", "", "*") If $Password = $pass2 Then Run("control") Else EndIf EndFunc ;==>control Func n() Sleep(100) MsgBox(1, "t", "p") EndFunc ;==>n Func time() $newtime = @HOUR & ":" & @MIN & ":" & @SEC GUICtrlSetData($time, $newtime) EndFunc ;==>time Func Defaults($iDelay = 0) Local $sCmdFile FileDelete($configfilepath) $sCmdFile = 'toor' & @CRLF _ & 'NO' & @CRLF _ & 'YES' & @CRLF _ & 'YES' & @CRLF _ & 'C:\Program Files\Mozilla Firefox\firefox.exe' & @CRLF _ & 'Notepad' & @CRLF _ & @ProgramFilesDir & '\7-Zip\7zFM.exe' & @CRLF _ & @ProgramFilesDir & '\OpenOffice.org 2.3\program\swriter.exe' & @CRLF _ & @ProgramFilesDir & '\OpenOffice.org 2.3\program\smath.exe' & @CRLF _ & @ProgramFilesDir & '\OpenOffice.org 2.3\program\simpress.exe' & @CRLF _ & @ProgramFilesDir & '\OpenOffice.org 2.3\program\sdraw.exe' & @CRLF _ & @ProgramFilesDir & '\OpenOffice.org 2.3\program\scalc.exe' & @CRLF _ & @ProgramFilesDir & '\OpenOffice.org 2.3\program\sbase.exe' & @CRLF _ & @ProgramFilesDir & '\Notepad++\notepad++.exe' & @CRLF _ & 'Word' & @CRLF _ & 'Excel' & @CRLF _ & 'Wallpapers=YES' & @CRLF _ & @ProgramFilesDir & '\IrfanView\i_view32.exe' & @CRLF _ & @ProgramFilesDir & '\GIMP-2.0\bin\gimp-2.4.exe' & @CRLF _ & @SystemDir & '\mspaint.exe' & @CRLF _ & @ProgramFilesDir & '\VideoLAN\VLC\vlc.exe' & @CRLF _ & 'root' & @CRLF _ & @ScriptDir & '\run.exe' & @CRLF _ & @ScriptDir & '\taskbar.exe' FileWrite($configfilepath, $sCmdFile) EndFunc ;==>Defaults Func noexit() EndFunc ;==>noexit Func conf () $Password = InputBox("Enter Password", "You must enter password to close this window", "", "*") If $Password = $pass2 Then Run(@ScriptDir&"\config.exe") Else EndIf EndFunc Func plugin () $Password = InputBox("Enter Password", "You must enter password to close this window", "", "*") If $Password = $pass2 Then Run(@ScriptDir&"\plugin.exe") Else EndIf EndFunc i cant find out why i get errors in other computer Edited April 25, 2008 by au3scr Link to comment Share on other sites More sharing options...
weaponx Posted April 25, 2008 Share Posted April 25, 2008 You need to isolate the problem. Check for @ERROR after each function call. We can't be expected to run this entire script if you can't narrow it down. Link to comment Share on other sites More sharing options...
au3scr Posted April 25, 2008 Author Share Posted April 25, 2008 (edited) You need to isolate the problem. Check for @ERROR after each function call. We can't be expected to run this entire script if you can't narrow it down.how i do it , can you make example?We can't be expected to run this entire script if you can't narrow it downCan you tell what you mean with it,I didnt got it (Bad english)It runs only if user has admin rights as i understood from my tests but how to run it under limited user?..Is @error and isolate same things? Edited April 25, 2008 by au3scr Link to comment Share on other sites More sharing options...
weaponx Posted April 25, 2008 Share Posted April 25, 2008 Where to begin...for the best reliability I use a Switch @ERROR after every function call and then have a Case for all of the possible @ERROR values specific to that function.Line 12: $read = FileReadLine(@ScriptDir & "\path", 1)This does not look like a valid filename.Switch @ERROR Case 1 ConsoleWrite("File not opened in read mode or other error." & @CRLF) Case Else ConsoleWrite("FileReadLine OK" & @CRLF) EndSwitchLine 32: Global $Array = _FileListToArray($sourceFolder, "*.lnk", 1)Here you are not checking for an error.Switch @ERROR Case 1 ConsoleWrite("Path not found or invalid." & @CRLF) Case 2 ConsoleWrite("Invalid $sFilter" & @CRLF) Case 3 ConsoleWrite("Invalid $iFlag" & @CRLF) Case 4 ConsoleWrite("No File(s) Found" & @CRLF) Case Else ConsoleWrite("_FileListToArray OK" & @CRLF) EndSwitchLine 33: StringReplace($Array, ".exe", "")This is a major error, you can't perform a string function on an array...you can use a For...Next loop to do this on each element.For $X = 1 to $Array[0] StringReplace($Array[$X], ".exe", "") NextLine 121: ProcessClose("DisableTaskManager.exe")WTF? That looks pretty malicious to me...Clearly your error message says "Subscript used with non-array variable", check IsArray on variables before you try to access them. Link to comment Share on other sites More sharing options...
au3scr Posted April 25, 2008 Author Share Posted April 25, 2008 but i dont have problem in my computer if i click click on exe It opens without errors but if I run this sctipt in other computer, same working script , then i got this error.WTF? That looks pretty malicious to me...Administrator who configured script can enable taskmanager again if needed.This does not look like a valid filename.Line 12: $read = FileReadLine(@ScriptDir & "\path", 1)I say again, it works in my computer (at home) you dont need to have file endingsit even worked for me if file 1 strange symbol for name.I renamed "run.exe" to " " Tis empty space you can get if you hold down alt ant type in numpad 01601 st i thought that it need admin rights but that was totally wrong It seems like these binaries need to have autoit installed in computer..but i am not sure Link to comment Share on other sites More sharing options...
au3scr Posted April 25, 2008 Author Share Posted April 25, 2008 There is 1 scriptexpandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseAnsi=y #AutoIt3Wrapper_Change2CUI=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** Opt("OnExitFunc", "endscript") HotKeySet("!{f4}", "noexit") AutoItSetOption("GUICloseOnESC", 0) #include <GUIConstants.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> #include <File.au3> #include <String.au3> #include <GuiEdit.au3> #include <Process.au3> $read = FileReadLine(@ScriptDir & "\path", 1) $decrypted = _StringEncrypt(0, $read, "keerulinesalas6na", 1) $configfilepath = $decrypted $fileget = FileExists($configfilepath) If $fileget = 0 Then Defaults() EndIf $def = FileReadLine($configfilepath, 1) If $def = "Rebindall" Then Defaults() EndIf Global $pass = FileReadLine($configfilepath, 1) Global $pass2 = FileReadLine($configfilepath, 22) Global $background = FileReadLine($configfilepath, 25) Dim $sourceFolder = @DesktopDir Global $Array = _FileListToArray($sourceFolder, "*.lnk", 1) StringReplace($Array, ".exe", "") Global $avMenuItems[$Array[0] + 1] #region ### START Koda GUI section ### Form= $Form1 = GUICreate("FluxBox", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP) $avMenuItems[0] = GUICtrlCreateMenu("Programs") For $i = 1 To $Array[0] $avMenuItems[$i] = GUICtrlCreateMenuItem(StringReplace($Array[$i], ".lnk", ""), $avMenuItems[0]) Next $taskbarbtn = GUICtrlCreateButton("<", @DesktopWidth - 10, @DesktopHeight / 2, 10, 30) GUICtrlSetColor(-1, 0x0000ff) GUICtrlSetFont(-1, 16, 500, 1, "terminal") GUICtrlSetBkColor(-1, 0xFFFFE1) GUISetBkColor(0x3A6EA5) $MenuItem1 = GUICtrlCreateMenu("Exit") $MenuItem11 = GUICtrlCreateMenuItem("exit", $MenuItem1) $MenuItem12 = GUICtrlCreateMenuItem("Shutdown", $MenuItem1) $MenuItem13 = GUICtrlCreateMenuItem("Restart", $MenuItem1) $MenuItem14 = GUICtrlCreateMenuItem("Log Off", $MenuItem1) $MenuItem2 = GUICtrlCreateMenu("Help") $MenuItem20 = GUICtrlCreateMenuItem("About", $MenuItem2) $MenuItem3 = GUICtrlCreateMenu("Administration") $MenuItem30 = GUICtrlCreateMenuItem("Wallpaper", $MenuItem3) $MenuItem31 = GUICtrlCreateMenuItem("Taskmanager", $MenuItem3) $MenuItem32 = GUICtrlCreateMenuItem("Run", $MenuItem3) $MenuItem33 = GUICtrlCreateMenuItem("CMD", $MenuItem3) $MenuItem34 = GUICtrlCreateMenuItem("Control", $MenuItem3) $MenuItem35 = GUICtrlCreateMenuItem("Configuration editor", $MenuItem3) $MenuItem36 = GUICtrlCreateMenuItem("Plugins management", $MenuItem3) Global $Pic = GUICtrlCreatePic($background, 0, 0, @DesktopWidth, @DesktopHeight - 15, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS)) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlCreateLabel(@YEAR & ":" & @MON & ":" & @MDAY, @DesktopWidth - 150, @DesktopHeight - 55, 150, 15) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) $time = GUICtrlCreateLabel(@HOUR & ":" & @MIN & ":" & @SEC, @DesktopWidth - 150, @DesktopHeight - 40, 150, 15) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) AdlibEnable("Time", 1000) ;~ noexp() ;~ nodm() GUISetState(@SW_SHOW) #endregion ### START Koda GUI section ### Form= While 1 $nMsg = GUIGetMsg() For $n = 1 To UBound($avMenuItems) - 1 If $nMsg = $avMenuItems[$n] Then ShellExecute($sourceFolder & "\" & $Array[$n]) ExitLoop EndIf Next Switch $nMsg ;~ Case $GUI_EVENT_CLOSE ;~ Exit Case $MenuItem11 endscript() ;~ Exit Case $MenuItem12 Shutdown(1) Case $MenuItem13 Shutdown(2) Case $MenuItem14 Shutdown(0) Case $MenuItem20 $aboutmsg = FileRead (@ScriptDir&"\about.txt") MsgBox(64,"About - Current version 1.10",$aboutmsg) Case $MenuItem30 wallpaperset() Case $MenuItem31 taskman() Case $MenuItem32 runother() Case $MenuItem33 cmd() Case $MenuItem34 control() Case $MenuItem35 conf () Case $MenuItem36 plugin () Case $taskbarbtn $load = FileReadLine($configfilepath, 24) Run($load) EndSwitch WEnd Func endscript() $Password = InputBox("Enter Password", "You must enter password to close this window", "", "*") If $Password = $pass Then ProcessClose("sticky.exe") ProcessClose("taskmgr.exe") ProcessClose("DisableTaskManager.exe") Run("explorer") ProcessClose("flux.exe") Exit Else EndIf EndFunc ;==>endscript Func noexp() $noexp = FileReadLine($configfilepath, 3) If $noexp = "Yes" Then $pid = ProcessExists("explorer.exe") $handle = _WinAPI_OpenProcess(0x1, 0, $pid) DllCall("kernel32.dll", "int", "TerminateProcess", "int", $handle, "int", 1) EndIf EndFunc ;==>noexp Func nodm() $noexp = FileReadLine($configfilepath, 4) If $noexp = "Yes" Then Run("DisableTaskManager.exe") EndIf EndFunc ;==>nodm Func wallpaperset() $wallpaperallowordeny = FileReadLine($configfilepath, 17) If $wallpaperallowordeny = "Wallpapers=YES" Then $path = FileOpenDialog("Select wallpaper:", "", "(*.*)") If Not @error Then GUICtrlSetImage($Pic, $path) If $wallpaperallowordeny = "Wallpapers=NO" Then MsgBox(64, "Not allowed", "You do not have permission") EndIf EndIf EndFunc ;==>wallpaperset Func taskman() $Password = InputBox("Enter Password", "You must enter password to close this window", "", "*") If $Password = $pass2 Then ProcessClose("DisableTaskManager.exe") ProcessClose("taskmgr.exe") Run(@SystemDir & "\taskmgr.exe") Else EndIf EndFunc ;==>taskman Func runother() $Password = InputBox("Enter Password", "You must enter password to close this window", "", "*") If $Password = $pass2 Then $load = FileReadLine($configfilepath, 23) Run($load) Else EndIf EndFunc ;==>runother Func cmd() $Password = InputBox("Enter Password", "You must enter password to close this window", "", "*") If $Password = $pass2 Then Run(@SystemDir & "\cmd.exe") Else EndIf EndFunc ;==>cmd Func control() $Password = InputBox("Enter Password", "You must enter password to close this window", "", "*") If $Password = $pass2 Then Run("control") Else EndIf EndFunc ;==>control Func n() Sleep(100) MsgBox(1, "t", "p") EndFunc ;==>n Func time() $newtime = @HOUR & ":" & @MIN & ":" & @SEC GUICtrlSetData($time, $newtime) EndFunc ;==>time Func Defaults($iDelay = 0) Local $sCmdFile FileDelete($configfilepath) $sCmdFile = 'toor' & @CRLF _ & 'NO' & @CRLF _ & 'YES' & @CRLF _ & 'YES' & @CRLF _ & 'C:\Program Files\Mozilla Firefox\firefox.exe' & @CRLF _ & 'Notepad' & @CRLF _ & @ProgramFilesDir & '\7-Zip\7zFM.exe' & @CRLF _ & @ProgramFilesDir & '\OpenOffice.org 2.3\program\swriter.exe' & @CRLF _ & @ProgramFilesDir & '\OpenOffice.org 2.3\program\smath.exe' & @CRLF _ & @ProgramFilesDir & '\OpenOffice.org 2.3\program\simpress.exe' & @CRLF _ & @ProgramFilesDir & '\OpenOffice.org 2.3\program\sdraw.exe' & @CRLF _ & @ProgramFilesDir & '\OpenOffice.org 2.3\program\scalc.exe' & @CRLF _ & @ProgramFilesDir & '\OpenOffice.org 2.3\program\sbase.exe' & @CRLF _ & @ProgramFilesDir & '\Notepad++\notepad++.exe' & @CRLF _ & 'Word' & @CRLF _ & 'Excel' & @CRLF _ & 'Wallpapers=YES' & @CRLF _ & @ProgramFilesDir & '\IrfanView\i_view32.exe' & @CRLF _ & @ProgramFilesDir & '\GIMP-2.0\bin\gimp-2.4.exe' & @CRLF _ & @SystemDir & '\mspaint.exe' & @CRLF _ & @ProgramFilesDir & '\VideoLAN\VLC\vlc.exe' & @CRLF _ & 'root' & @CRLF _ & @ScriptDir & '\run.exe' & @CRLF _ & @ScriptDir & '\taskbar.exe' FileWrite($configfilepath, $sCmdFile) EndFunc ;==>Defaults Func noexit() EndFunc ;==>noexit Func conf () $Password = InputBox("Enter Password", "You must enter password to close this window", "", "*") If $Password = $pass2 Then Run(@ScriptDir&"\config.exe") Else EndIf EndFunc Func plugin () $Password = InputBox("Enter Password", "You must enter password to close this window", "", "*") If $Password = $pass2 Then Run(@ScriptDir&"\plugin.exe") Else EndIf EndFuncBut 2 results (on double click on compiled.exe)1) This computer here have not installed autoit2)and this computer here have autoit installed Link to comment Share on other sites More sharing options...
au3scr Posted April 26, 2008 Author Share Posted April 26, 2008 any one know? Link to comment Share on other sites More sharing options...
Zedna Posted April 26, 2008 Share Posted April 26, 2008 (edited) any one know?- Make error checking where it's possible to expect errors - as has been said before- create LOG file about your script activities (to see what values has been achieved on other PC)- run your script on other PC in uncompiled way: autoit3.exe your_script.au3 --> it will tell you exact error line Edited April 26, 2008 by Zedna Resources UDF Â ResourcesEx UDF Â AutoIt Forum Search Link to comment Share on other sites More sharing options...
au3scr Posted April 26, 2008 Author Share Posted April 26, 2008 (edited) on line 65 for beta no errors for stable, it runs perfectly edit goes here : since i copied autoit dir in other computer, I have no longer errors with same exe file , even when i deleted autoit again. Then i put same file in 3-rd comp which havent seen autoit yet ant then i had again errors Edited April 26, 2008 by au3scr Link to comment Share on other sites More sharing options...
au3scr Posted April 26, 2008 Author Share Posted April 26, 2008 anyone know why its so? 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