Sign in to follow this  
Followers 0
myspacee

Read until a point

10 posts in this topic

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.

Share this post


Link to post
Share on other sites



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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Thank you for reply,

I think same thing, but some path has ' ' (space) [eg: c:\program files\appdata\]

m.

Share this post


Link to post
Share on other sites

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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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...

Share this post


Link to post
Share on other sites

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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

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")
;

Share this post


Link to post
Share on other sites

thank you all,

use Malkey solution, excellent.

m.

Share this post


Link to post
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
Sign in to follow this  
Followers 0