Jump to content

Error on folders


Recommended Posts

Hey,

For part of my program I am allowing people to run programs from a desktop. If the program is a .exe then it will run, if its a folder it doesnt work.

I have tried If @error then MsgBox() but it doesnt work.

Here is what I have so far.

Func _RunProg()
    $Readme = _GUICtrlListViewGetItemText($mList, _GUICtrlListViewGetSelectedIndices($mList))
    $mList = _GUICtrlListViewGetItemText($mList, 0)
    ; If $mList = "My Computer" Then MsgBox(0, "File Run", "Found My Computer")
    If PathIsDir($mList) Then
        MsgBox(0x10, "Error", "You cannot run a folder.")
    Else
    ShellExecuteWait($Readme, @DesktopDir, @SW_MAXIMIZE)
    EndIf
EndFunc   ;==>_RunProg

James

Link to comment
Share on other sites

PathIsDir() is not a built-in AutoIt function. You didn't include Manadar's little UDF:

Func PathIsDir($s_Path) ; if the path entered is a directory, it returns a number bigger then zero. If it is not it returns 0.
    $s_Attrib = FileGetAttrib($s_Path)
    Return StringInStr($s_Attrib,"D",1)
EndFunc

If it was actually included elsewhere, your script fragment looks like it should work. If you still have a problem, use a debug MsgBox() or ConsoleWrite() to make sure $mList really has the path in it.

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...