Jump to content

GuiCtrlRead from GuiCtrlCreateList Set Data


Recommended Posts

Ok here it is in a nutshell, I am trying to read data from a list then execute the list. This works great and fine unless the file I am launching happens to have spaces.

If @OSArch = "X86" Then
    $OS = "C:\Program Files\"
Else
    $OS = "C:\Program Files (X86)\"
EndIf
$cmtrace = $OS & "CMTrace.exe"


$LogViewer = GUICreate("Log Files", 562, 359, 192, 124)
$RemotePCInput = GUICtrlCreateInput("", 144, 8, 273, 21)
$RemotePCLab = GUICtrlCreateLabel("Remote PC", 8, 8, 128, 17)
$LogList1 = GUICtrlCreateList("", 8, 40, 257, 253)
$LogList2 = GUICtrlCreateList("", 280, 40, 257, 253)
$Log1ListButton = GUICtrlCreateButton("Read Log", 28, 304, 113, 49)
$Log2LISTBUTTON = GUICtrlCreateButton("Read Log", 300, 304, 113, 49)
$RemotePCConnect = GUICtrlCreateButton("Connect", 432, 8, 65, 25)
GUISetState(@SW_SHOW)

Func LogViewer()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $RemotePCConnect
            $PingRemoteMachine = Ping(GUICtrlRead($RemotePCInput))
            If $PingRemoteMachine = True Then
                GUICtrlSetData($LogList1,"")
                GUICtrlSetData($LogList2,"")
                $Log1FileFind = _FileListToArray("\\" & GuiCtrlRead($RemotePCInput) & "Log1 Location", "*.log")
                $Log2FileFind = _FileListToArray("\\" & GuiCtrlRead($RemotePCInput) & "Log2 Location", "*.log")
                _ArrayDelete($Log1FileFind,0)
                _ArrayDelete($Log2FileFind,0)
                GUICtrlSetData($LogList1,_ArrayToString($Log1LFileFind))
                GUICtrlSetData($LogList2,_ArrayToString($Log2FileFind))
            ElseIf $PingRemoteMachine = False Or GuiCtrlRead($RemotePCInput) = "" or StringLen(GUICtrlRead($RemotePCInput)) < 10 or StringLen(GUICtrlRead($RemotePCInput)) > 10 Then
                MsgBox(0,"Connection",GUICtrlRead($RemotePCInput) & " is not connecting please confirm computer name is correct and online.")
            EndIf
        Case $Log1ListButton
            If GuiCtrlRead($RemotePCInput) = "" or StringLen(GUICtrlRead($RemotePCInput)) < 10 or StringLen(GUICtrlRead($RemotePCInput)) > 10 Then
                MsgBox(0,"Error","PC name is missing or not the appropriate length of characters.")
            ElseIf FileExists($CMTrace) = False Then
                ShellExecute("\\" & GuiCtrlRead($RemotePCInput) & "log location" & GUICtrlRead($LogList1))
            ElseIf FileExists($CMTrace) = True Then
                ShellExecute($CMTrace,"\\" & GUICtrlRead($RemotePCInput) & "log location" & GuiCtrlRead($LogList1))
            EndIf

        Case $Log2LISTButton
            If GuiCtrlRead($RemotePCInput) = "" or StringLen(GUICtrlRead($RemotePCInput)) < 10 or StringLen(GUICtrlRead($RemotePCInput)) > 10 Then
                MsgBox(0,"Error","PC name is missing or not the appropriate length of characters.")
            ElseIf $CMTrace = True Then
                ShellExecute($CMTrace,"\\" & GUICtrlRead($RemotePCInput) & "log location" & GuiCtrlRead($LogList2))
            ElseIf $CMTrace = False Then
                ShellExecute("\\" & GuiCtrlRead($RemotePCInput) & "log location" & GuiCtrlRead($LogList2))
            EndIf
            



    EndSwitch
WEnd
EndFunc

Now my issue is I have already thrown msgboxes in to confirm that is reads the full file name being test test.log is read out completely when I throw a msgbox to read loglist1 and loglist2 but it will execute with test and no space or file extension as in test test.log will try to kick off as test.   Maybe I am over looking something simple or am just plainly misusing or understanding how shell execute works with launching specific files within a specific program.

 

I have also thrown single quotes in the front and end of the logs when launching CMtrace and it makes no difference, also tried replacing white spaces with _ and that makes no difference. Any insight would be greatly appreciated. :)

 

Also sorry for the messiness, I had to remove some proprietary information ><

 

ALSO wanted to add I tried some stringtrim and replaces to add .log into the shellexecute to see if maybe forcing it to add another step would help but it does not, stringtrim and replace where I would use it is negligible.

Edited by tweakster2010
Corrected some missing code (CMTrace path was missing from the example)
Link to comment
Share on other sites

ShellExecute($CMTrace,"\\" & GUICtrlRead($RemotePCInput) & "log location" & GuiCtrlRead($LogList1))

To

Shellexecute($CMTrace, '"\\' & GUICtrlRead($RemotePCInput) & "log location" & GuiCtrlRead($LogList1) & '"')

fixed the issue with this topic. 

 

Solution was to change 

ShellExecute($CMTrace,"\\" & GUICtrlRead($RemotePCInput) & "log location" & GuiCtrlRead($LogList1))

To

Shellexecute($CMTrace, '"\\' & GUICtrlRead($RemotePCInput) & "log location" & GuiCtrlRead($LogList1) & '"')
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...