--- In [email protected], "aviasd" <[EMAIL PROTECTED]> wrote:
>
> --- In [email protected], "Sheri" <sherip99@> wrote:
> >
> > --- In [email protected], "aviasd" <aviasd@> 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.
> > 
> 
> Thanks ! a new range of posibilities just opened up :)
> > > 
> > > 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
> >
> actually this does not work , i think i know the reason - when i type
> commands by command line i usaully dont write the full path but rather
> then shortand version - consider this :
> notepad c:\1.txt
> OR:
> c:\essentials2\tot\totalcmd 
> /I="c:\essentials2\tot\Profiles\Prof\AVIELPC.ini"
> /F="c:\essentials2\tot\Profiles\Prof\ftp.ini" ""
> 
> sometimes i provide the path and sometimes not.
> anyway - this modified version worked for me :
> 
> 
> local clipcontent=clip.get
> clip.clear
> local apphandle=win.handle("active")
> 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)^(.+?)\x22? ", "\\1")
> local resparams= regex.m1(commandline, ?"(?i)^.+?\x22? +(.+)", "\\1")
> 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
> 
> 
> thanks a lot for your help !
> regards ,
> Avi
>
sorry - small regex fix : 

local commandline= ;;+
regex.pcrereplace(?"^CommandLine|\x20*\R\x20*|\x20+$",res,"")
local rescmd=regex.m1(commandline, ?"(?i)^(.+?\x22?) ", "\\1")
local resparams= regex.m1(commandline, ?"(?i)^.+?\x22? +(.+)", "\\1")


Reply via email to