Jump to content

Recommended Posts

Posted

I want to find a filename from a registry value after using the regread command; for example:

[HKEY_CURRENT_USER\Software\Classes\http\DefaultIcon]

@="\"C:\\Program Files\\Opera\\Opera.exe\",1"

or

[HKEY_CURRENT_USER\Software\Classes\http\shell\open\command]

@="\"C:\\Program Files\\Internet Explorer\\IEXPLORE.EXE\" -nohome"

or

[HKEY_CURRENT_USER\Software\Classes\http\shell\open\command]

@="\"C:\\Program Files\\Mozilla Firefox\\firefox.exe\" -requestPending -osint -url \"%1\""

So, I want to find the executable filename whatever it may be, but I don't know how to use the flags or delimiters in StringRegExp.

Posted

Search for _GetDefaultBrowser() by wakillon, he uses a well constructed SRE.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

  • Moderators
Posted

ffdshow,

This works for the strings you posted: :D

$sKey = '@=""C:Program FilesOperaOpera.exe",1"'
$sFileName = StringRegExpReplace($sKey, '.*(.*)"[s,].*', "$1")
ConsoleWrite($sFilename & @CRLF)

$sKey = '@=""C:\Program Files\Internet Explorer\IEXPLORE.EXE" -nohome"'
$sFileName = StringRegExpReplace($sKey, '.*(.*)"[s,].*', "$1")
ConsoleWrite($sFilename & @CRLF)

$sKey = '@=""C:Program FilesMozilla Firefoxfirefox.exe" -requestPending -osint -url "%1""'
$sFileName = StringRegExpReplace($sKey, '.*(.*)"[s,].*', "$1")
ConsoleWrite($sFilename & @CRLF)

SRE explanation:

.*    - Characters up to a  (we need to escape  with another  so we need  to match )
(.*)      - Capture the characters until...
"[s,]  - another backslash followed by a " and either a space or a comma (again we need to escape the )
.*        - And then another bunch of characters

$1        - Replace all the above with the captured group

Because SREs are naturally greedy, the initial section goes all the way to the last on its own. :)

All clear? ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

Posted

Easy way could also be:

#include <array.au3>
;~ $str = '@=""C:\Program Files\Internet Explorer\IEXPLORE.EXE" -nohome"'
;~ $str = '@=""C:Program FilesOperaOpera.exe",1"'
$str = '@=""C:Program FilesMozilla Firefoxfirefox.exe" -requestPending -osint -url "%1""'
$re = StringRegExp($str, '(?i)([^]*.exe)', 3)
_ArrayDisplay($re)

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...