Registry reading problem vb.net 2005

  • Thread starter Thread starter Sid Price
  • Start date Start date
S

Sid Price

I am having an issue reading a string value from the registry, with the
following code I get a pair of double quotes ("") at the start and end of
the string, this causes the method that processes the string to fail. Can
anyone advise what I am doing wrong please? Note that when I use regedit to
look at the value of the entry I do see it delimited by double quotes
("C:\Data Root\Projects\Pacific\Code\VistaMax\Tools 500 Series\VistaMax
Network Manager\VistaMaxRDS\bin\Release\VistaMaxRDS.exe"). The value
returned by GetValue is displayed like this in a watch window ""C:\Data
Root\Projects\Pacific\Code\VistaMax\Tools 500 Series\VistaMax Network
Manager\VistaMaxRDS\bin\Release\VistaMaxRDS.exe"".
Dim strRegKey As String = Registry.LocalMachine.ToString &
"\System\CurrentControlSet\Services\" _

& mService.ServiceName

Dim strImagePath As String = Registry.GetValue(strRegKey, "ImagePath", "")

Dim strPathOnly As String = System.IO.Path.GetFullPath(strImagePath) <-
this fails

Thanks,

Sid.
 
You may not be doing anything wrong. Some service paths in the registry are
indeed quoted in the registry, so your code will need to deal with that.
There's a security issue with unquoted paths that can be used to run the
wrong program, and quotes correct it.
 
Phil Wilson said:
You may not be doing anything wrong. Some service paths in the registry
are indeed quoted in the registry, so your code will need to deal with
that. There's a security issue with unquoted paths that can be used to run
the wrong program, and quotes correct it.
--
That is what I figured too, I have added code to detect and remove the extra
quotation marks and my application now operates as expected.
Thanks,
Sid.
 
Back
Top