Jump to content

Help with signs


Recommended Posts

Hi, I'm new here. I'm Spanish, so sorry for my English. My problem is this: I have these paths extracted of a value reg:

Regedit --> "C:\windows\regedit.exe -s /hide ('System')"

other reg --> C:\windows\otherfile.exe

other reg2 --> C:\windows\otherfile2.exe

other reg3 --> C:\windows\otherfile3.exe -h

other reg4 --> C:\windows\otherfile4.exe /local

I just want the path of all:

C:\windows\regedit.exe

C:\windows\otherfile.exe

C:\windows\otherfile2.exe

C:\windows\otherfile3.exe

C:\windows\otherfile4.exe

But some paths have other signs after the extension. I've tried to do it with this function "StringSplit" for to delimit the signs and get only the path, but this sign can be in the path. For example:

Other reg --> "C:\windows\other-file.exe

So, I've tried with this function "_PathSplit":

For $i = 1 To 100
Local $var = RegEnumVal("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", $i)
If @error <> 0 Then ExitLoop
Local $var2 = Regread("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", $var)
Local $szDrive, $szDir, $szFName, $szExt
Local $TestPath = _PathSplit($var2, $szDrive, $szDir, $szFName, $szExt)
msgbox(0,"",$TestPath[1] & $TestPath[2] & $TestPath[3] & ".exe",0)
Next

I think that with this example would extract the path, but it extract all, including -s /hide ('System')",-h,/local...etc

thank you for your consideration of this matter and sorry for the wrong words.

Link to comment
Share on other sites

hi mate, maybe you can use stringmid to get only the extension.

#include <File.au3>
#include <Array.au3>

Local $szDrive, $szDir, $szFName, $szExt
$claveleida="C:windowsotherfile3.exe -h"
Local $TestPath = _PathSplit($claveleida, $szDrive, $szDir, $szFName, $szExt)
$splitextension=StringMid($szExt,1,4)
msgbox(0,"",$TestPath[1]&$TestPath[2]&$TestPath[3]&$splitextension)

Saludos ;) también hablo español.

Edited by Danyfirex
Link to comment
Share on other sites

Hi DanyFirex, thanks for help. Your code works, but only works with your string. I need to do this with all values that I get, obviously, I ignore if the value is normal or it has signs after path. If value is normal, get the path, it's easy... But, get the path without signs it's difficult.

I need obviate the final signs, in other words, I need the path, from first word of drive to the final word of extension.

Link to comment
Share on other sites

ok right :idea: so use stringsplit, You split the extension ontil " " one space.

look

#include 
#include 

Local $szDrive, $szDir, $szFName, $szExt
$claveleida="C:windowsotherfile3.exe -h"
Local $TestPath = _PathSplit($claveleida, $szDrive, $szDir, $szFName, $szExt)
$splitextension=StringSplit($szExt," ")
msgbox(0,"",$TestPath[1]&$TestPath[2]&$TestPath[3]&$splitextension[1])
Link to comment
Share on other sites

Try this:

$i = 1
While True
    Local $var = RegEnumVal("HKLMSOFTWAREMicrosoftWindowsCurrentVersionRun", $i)
    If @error <> 0 Then ExitLoop
    Local $var2 = Regread("HKLMSOFTWAREMicrosoftWindowsCurrentVersionRun", $var)
    Local $sRes = StringRegExpReplace($var2, '["]|(.*w+.w+)(.*)', "$1")
    If $sRes <> "" Then ConsoleWrite($var2 & @LF & $sRes & @LF & @LF)
    $i += 1
WEnd

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

  • Moderators

Look up StringRegExpReplace in the help file, and you will be able to read all about it.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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