如何通过vb.net使用注册表编辑器启动任何应用程序?

如何通过vb.net使用注册表编辑器启动任何应用程序?,vb.net,Vb.net,在Vb.Net中,要加载任何应用程序(例如,Internet Explorer),我们可以使用其路径启动它 System.Diagnostics.Process.Start("C:\Program Files\Internet Explorer\iexplore.exe") 是否有任何方法可以使用注册表编辑器加载相同的应用程序。因为在安装任何应用程序之前,该应用程序将在系统的注册表编辑器中注册自身。那么,是否有任何方法可以使用注册表编辑器调用相同的应用程序(例如,Internet Explo

在Vb.Net中,要加载任何应用程序(例如,Internet Explorer),我们可以使用其路径启动它

 System.Diagnostics.Process.Start("C:\Program Files\Internet Explorer\iexplore.exe")

是否有任何方法可以使用注册表编辑器加载相同的应用程序。因为在安装任何应用程序之前,该应用程序将在系统的注册表编辑器中注册自身。那么,是否有任何方法可以使用注册表编辑器调用相同的应用程序(例如,Internet Explorer?

'我相信您希望从注册表获取可执行文件的路径。应用程序可以将其存储在AppPath下(请参见代码)。因为路径中可能有空格,所以需要用引号括起来。这显然是下面的VBScript代码

function readAppPathFromRegistry (strExecutable, strDefault)
    Dim WSHShell, value


    On Error Resume Next
    Set WSHShell = CreateObject ("WScript.Shell")
    value = WSHShell.RegRead ("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\" & strExecutable & "\")

    if err.number <> 0 then
        readAppPathFromRegistry = strDefault
    else
        readAppPathFromRegistry = value
    end if

    set WSHShell = nothing
end function

function startApplication(strExecutable)
    Dim strAppPath
    Dim WShellApp



    strAppPath = readAppPathFromRegistry ( strExecutable, "") 
    if (strAppPath = "") then
        strAppPath = strExecutable
    end if
    Set WShellApp = CreateObject("WScript.Shell")
    strAppPath = """" & strAppPath & """"
    WScript.echo strAppPath
    WShellApp.Run strAppPath, 1, false
end function

startApplication "iexplore.exe"
函数readAppPathFromRegistry(strExecutable,strDefault)
Dim WSHShell、值
出错时继续下一步
设置WSHShell=CreateObject(“WScript.Shell”)
value=WSHShell.regrad(“HKEY\U LOCAL\U MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App path\”&strExecutable&“\”)
如果错误号为0,则
readAppPathFromRegistry=strDefault
其他的
readAppPathFromRegistry=值
如果结束
设置WSHShell=nothing
端函数
功能启动应用程序(可执行)
暗道
Dim WShellApp
StrapPath=readAppPathFromRegistry(strExecutable,“”)
如果(路径=),则
StrapPath=Streexecutable
如果结束
设置WShellApp=CreateObject(“WScript.Shell”)
StrapPath=“”&StrapPath&“”
WScript.echo路径
WShellApp.Run路径,1,false
端函数
startApplication“iexplore.exe”

您所说的“使用编辑器加载相同的应用程序”是什么意思?注册表编辑器是操作注册表的工具,而不是启动应用程序。您能解释一下吗?我猜应用程序的路径写在注册表项中,您希望从注册表获取可执行文件的路径,并将其传递给
进程。Start()
,对吗?可能的重复。这个问题的公认答案回答了我刚才描述的问题。你说的是错误的:1-[无法]使用注册表编辑器加载应用程序。2-应用程序未在注册表编辑器中注册。。。。考虑一下,该值作为(默认值)存储在注册表中,在使用registry.GetValue Method()方法时,可以通过使用“”或valueName参数为null来获取