myspacee Posted August 3, 2009 Share Posted August 3, 2009 hello to all, try to write a toolbar that run different exe with parameters. Find some obstacles reading command from given .ini: __________________mycommand.ini [option] CMD_01=C:\WINDOWS\notepad.exe CMD_02=C:\WINDOWS\regedit.exe CMD_03=C:\Programmi\Windows NT\Accessori\wordpad.exe c:\autoexec.bat In this case last specified command [CMD_03] contains a parameter [c:\autoexec.bat] I have some problem to identify application path [worpad -> C:\Programmi\Windows NT\Accessori\] to pass this to runwait() function. Some application to work need right path to work properly. ["workingdir"] RunWait ( "filename" [, "workingdir" [, show_flag [, opt_flag ]]] ) I think to read until first '.exe' and then _PathSplit() this, but don't know how do this. Have any idea how is possible to extract from C:\Programmi\Windows NT\Accessori\wordpad.exe c:\autoexec.bat only MAIN exe path ? C:\Programmi\Windows NT\Accessori\ Thank you for any suggestion, m. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 3, 2009 Moderators Share Posted August 3, 2009 myspacee,StringSplit on " " first and then _PathSplit element[1] of the resulting array.M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
myspacee Posted August 3, 2009 Author Share Posted August 3, 2009 Thank you for reply, I think same thing, but some path has ' ' (space) [eg: c:\program files\appdata\] m. Link to comment Share on other sites More sharing options...
gkrapp Posted August 3, 2009 Share Posted August 3, 2009 Hi, @ProgramFilesDir should help you in MUI environments. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 3, 2009 Moderators Share Posted August 3, 2009 myspacee,Good point - I should have thought of that myself!Are all your commands for .exe files? If so, then StringSplit on ".exe " before using _PathSplit.What have I overlooked this time?M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
myspacee Posted August 4, 2009 Author Share Posted August 4, 2009 thank you both for reply, think use '.exe' for split but if i've not any parameter after .exe return to me an array error. (any element) Is not possible to read string until first text occurance ? [.exe] or stringbetween from [=] to [.exe] ? ______=_______________________-.exe m. Link to comment Share on other sites More sharing options...
gkrapp Posted August 4, 2009 Share Posted August 4, 2009 Hi, of course i - by myself - would currently not be able to code it, but would it be possible to use StringRegExp to check if there is a "blank" follwed by a "driveletter [a-z]" followed by a ":\" to divide the command line? Just an idea... Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 4, 2009 Moderators Share Posted August 4, 2009 myspacee, I would bet that you are not using the correct flag parameter for StringSplit - you need to tell it to use all the ".exe" to split. This code should work for you: Global $asText[3] $asText[0] = "C:\WINDOWS\notepad.exe" $asText[1] = "C:\WINDOWS\regedit.exe" $asText[2] = "C:\Programmi\Windows NT\Accessori\wordpad.exe c:\autoexec.bat" For $i = 0 To 2 ; Split on ".exe" using the flag parameter $asResult = StringSplit($asText[$i], ".exe", 1) ; Find the final \ $iPos = StringInStr($asResult[1], "\", 0, -1) ; Get the string up to the \ ConsoleWrite(StringMid($asResult[1], 1, $iPos -1) & @CRLF) Next M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Malkey Posted August 4, 2009 Share Posted August 4, 2009 Another example. ; Opt("WinTitleMatchMode", 2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase Local $Pid, $var, $sExe, $sWorhDir, $sFilePathName, $sFileName IniWrite(@ScriptDir & "\myfile.ini", "option", "CMD_01", @WindowsDir & '\notepad.exe "' & @ScriptDir & '\myfile.ini"') IniWrite(@ScriptDir & "\myfile.ini", "option", "CMD_02", @WindowsDir & '\regedit.exe') IniWrite(@ScriptDir & "\myfile.ini", "option", "CMD_03", 'C:\Program Files\Windows NT\Accessories\wordpad.exe "' & @ScriptDir & '\myfile.ini"') For $x = 1 To 3 $var = IniRead(@ScriptDir & "\myfile.ini", "option", "CMD_0" & $x, "NotFound") $sExe = StringRegExpReplace($var, "(.*\.exe)(.*)$", "\1") $sWorhDir = StringRegExpReplace($var, '(.*\.exe) "(.*)(\\.*)$', "\2") $sFilePathName = StringRegExpReplace($var, '(.*\.exe)( "){0,1}(.*\..{3})("{0,1})$', "\3") $sFileName = StringRegExpReplace($var, '(.*\.exe)(.*".*\\)(.*\..{3})"$', "\3") $Pid = Run($var) If $var <> $sExe Then ;RunWait($sExe, $sWorhDir, Default) WinWait($sFileName, "") EndIf MsgBox(4096, "Result for option CMD_0" & $x, "$var: " & @TAB & $var & @CRLF & "$sExe: " & @TAB & $sExe & @CRLF & "$sWorhDir: " & @TAB & $sWorhDir & @CRLF & _ "$sFilePathName: " & @TAB & $sFilePathName & @CRLF & "$sFileName: " & @TAB & $sFileName) If ProcessExists($Pid) Then ProcessClose($Pid) Next If FileExists(@ScriptDir & "\myfile.ini") Then FileDelete(@ScriptDir & "\myfile.ini") ; Link to comment Share on other sites More sharing options...
myspacee Posted August 5, 2009 Author Share Posted August 5, 2009 thank you all, use Malkey solution, excellent. m. 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