--- In [email protected], "aviasd" <[EMAIL PROTECTED]> wrote:
>
> Thanks for your help sherri
> I used your first script with a few tweaks
>
> I need to handle two more things - when wmic returns more than one
> process - I need to restart only the first result - where can I find
> documentation on regex.pcrereplace ? (have not found it anywhere !)
You should have regex.chm in your powerpro plugins directory.
>
> and secondly , I need to split the command line from it's parameters
> or else I get file not found on do() command - or is there any other
> way to just run the whole line and be done with it ?
OK, well we don't have to get the commandline based on the exe name,
we can get it based on the processid (which PowerPro can give us).
That way we only get back one commandline. I think "do" can use that
commandline (after regex) without separating the exe and the
parameters (at least it works with notepad and various documents), but
I separated them anyway just in case.
Try the version below.
Regards,
Sheri
local clipcontent=clip.get
clip.clear
local apphandle=win.handle("under")
local appprocess=win.getprocessid(apphandle)
;local appname=win.exename(apphandle)++".exe"
local wmicmd= ;;+
?"/c wmic /output:clipboard process "++appprocess++" GET commandline"
file.runwait(0, env("COMSPEC"), wmicmd, "", "hide")
local res=clip.get
clip.set(clipcontent)
win.terminateprocess(appprocess)
local commandline= ;;+
regex.pcrereplace(?"^CommandLine|\x20*\R\x20*|\x20+$",res,"")
local rescmd=regex.m1(commandline, ?"(?i)^.+?\.exe\x22?", "\\0")
local resparams= ;;+
regex.m1(commandline, ?"(?i)^.+?\.exe\x22?+ *+\K.+", "\\0")
do(rescmd,resparams)
;win.debug("restored clipboard", clip.get)
;win.debug("res", res)
;win.debug("commandline", commandline)
;win.debug("rescmd", rescmd)
;win.debug("resparams", resparams)
quit