Jump to content

- RegRead, I Need name only


Recommended Posts

Hi everyone,

Key   = HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\AutorunsDisabled
value = SunJavaUpdateSched

Using RegRead()Return "C:\Program Files\Java\jre1.6.0_06\bin\jusched.exe" ,Thats Cool

All i need "jusched.exe", i need name only not showing full path!?

NB: The RegKey above is just an example, "jusched.exe" & "RegKey" maybe anything else.

I dont like StringRight() function, is there something better?

Link to comment
Share on other sites

Here's a little function that will give you the correct value.

Note : This only works if the return is a file path I.E. "C:\Program Files\Java\jre1.6.0_06\bin\jusched.exe" it will return jusched.exe.

Code :

Func _GetValue ($iData)
$Split = StringSplit ($iData, '\')
Return $Split[$Split[0]]
EndFunc

Hope this helps! >_<

- John

Latest Projects :- New & Improved TCP Chat

Link to comment
Share on other sites

Firstly, thank you so much

I told you before, "RegKey" maybe anything Ex: Regread return "C:\Program Files\Notebook Hardware Control\nhc.exe" -quiet

Your Func will return, nhc.exe" -quiet

maybe other idea!, thanks again

Link to comment
Share on other sites

My RegExp skills are bit lacking, but still. >_< This will (I hope) match anything from \ to " or \"

$string='"C:\Program Files\Notebook Hardware Control\nhc.exe" -quiet'
$pattern='.*\\(.+?)[\\"]'
$search=StringRegExp($string,$pattern,1)
If Not @error Then 
    $search=$search[0]
    MsgBox(0,"",$search)
EndIf

I suppose it can be improved to match end of line... I am no good with end of lines and regexp.

Edited by Rarst
Link to comment
Share on other sites

Here's a re-write of my function this time it should do the job.

Code :

Func _GetValue ($iData)
$IllegalChars = '\/:*?<>|"'
$IllegalChars = StringSplit ($IllegalChars, '')
$Split = StringSplit ($iData, '\')
$Return = $Split[$Split[0]]
For $A = 1 To $IllegalChars[0]
$Return = StringReplace ($Return, $IllegalChars[$A],'')
Next
Return $Return
EndFunc

Hope this helps! >_<

- John

Latest Projects :- New & Improved TCP Chat

Link to comment
Share on other sites

$sVal = RegRead("SomeKey", "SomeValue")
$sVal = StringRegExpReplace($sVal, "(.*\\)(.*)", "$2")

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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...