11 Years of Service
51%
[HIDE-THANKS]This UDF takes a raw string and parses it into command and parameters variables, which it passes to ShellExecute() -- or ShellExecuteWait() if variable $vWait is set. I use it to read command strings from an .ini file, which can be executed by entering a short alias, or key. For example, with the following .ini entry I can open the NY Times website in Firefox by simply entering "N":
N="C:\Program Files (x86)\Mozilla Firefox\firefox.exe"
ShellExecuteRaw() parses the command string into command and parameter(s), and then returns ShellExecute[Wait]().
[/HIDE-THANKS]
N="C:\Program Files (x86)\Mozilla Firefox\firefox.exe"
This link is hidden for visitors. Please Log in or register now.
ShellExecuteRaw() parses the command string into command and parameter(s), and then returns ShellExecute[Wait]().
Code:
>Func ShellExecuteRaw($R, $vWorkingDir="", $vVerb="", $vWait="")
#cs
Format raw string as "command", "params" for ShellExecute[Wait]()
Variables: $R = raw string; $C = command; $D = delimiter; $P = params
If input var $vWait is set, func returns
ShellExecuteWait($C, $P, $vWorkingDir, $vVerb)
otherwise, it returns
ShellExecute($C, $P, $vWorkingDir, $vVerb)
#ce
Local $C = $R, $D = " ", $P = ""
If StringInStr($R, '"') == 1 Then
$D = '" '
EndIf
If StringInStr($R, $D) > 0 Then
$C = StringTrimRight( $R, StringLen($R) _
- StringinStr($R, $D) + 2 - StringLen($D) )
$P = StringTrimLeft( $R, StringInStr($R, $D) )
EndIf
Local $ShellFuncName = "ShellExecute"
If $vWait Then
$ShellFuncName = $ShellFuncName & "Wait"
EndIf
Return Call($ShellFuncName, $C, $P, $vWorkingDir, $vVerb)
EndFunc ; ShellExecuteRaw