Sign in to follow this  
Followers 0
DCCD

- RegRead, I Need name only

7 posts in this topic

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?

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

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

Share this post


Link to post
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

Share this post


Link to post
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!"

Share this post


Link to post
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
Sign in to follow this  
Followers 0