windows - Rewriting a string in AutoIt works once, but not the second time -
i working on autoit code me office pranks , stuff. first string works rewrite string "shutdown pc00xxx" shutdown /r /m pc00xxx /t 0
, can't second string re.
i have following code:
func runproc($string) local $command = stringlower($string) local $subs = stringmid($command, 1, 4) local $computer = stringinstr($command, "pc") if $subs == "shut" run("shutdown /r /m " & stringmid($command, $computer) & " /t 0") elseif $subs == "clos" local $prleft = stringtrimleft($command, 6) local $extend = stringinstr($command, "on") local $pright = stringtrimright($prleft, $extend) local $strclose = stringmid($string, $prleft, $pright) run("taskkill.exe /s "& stringmid($command, $computer) & " /im " & $strclose & ".exe") endif
the problem trying rewrite phrase "close "something" on "pc00xxx" taskkill.exe /s pc00xxx /im something.exe, trying substring between "close " , " on pc00xxx.
so, example, type close outlook on pc00xxx , have value of $strclose be:
$strclose = outlook
try this:
$string = 'close outlook on pc00xxx' $amatch = stringregexp($string, '(?i)close (.+) on pc.+', 1) if isarray($amatch) consolewrite('app: ' & $amatch[0] & @crlf)
Comments
Post a Comment