这是一种不使用CMD ,shell或批处理文件:
首先,您的设置 - 应用程序需要被允许在注册表中写入。您可以achive通过设置你的 “requestedExecutionLevel” 到 “highestAvailable”:
文件: “app.manifest”
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
现在你可以使用你的DotNetFramework函数来创建你卸载的RegistryKey:
'Setting My Values
Dim ApplicationName As String = "Yourapp"
Dim ApplicationVersion As String = "1.0.0.0"
Dim ApplicationIconPath As String = "%PROGRAMFILES%\Yourapp\yourapp.ico"
Dim ApplicationPublisher As String = "Yourname"
Dim ApplicationUnInstallPath As String = "%PROGRAMFILES%\Yourapp\UNINSTALL.exe"
Dim ApplicationInstallDirectory As String = "%PROGRAMFILES%\Yourapp\"
'Openeing the Uninstall RegistryKey (don't forget to set the writable flag to true)
With My.Computer.Registry.LocalMachine.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Uninstall", True)
'Creating my AppRegistryKey
Dim AppKey As Microsoft.Win32.RegistryKey = .CreateSubKey(ApplicationName)
'Adding my values to my AppRegistryKey
AppKey.SetValue("DisplayName", ApplicationName, Microsoft.Win32.RegistryValueKind.String)
AppKey.SetValue("DisplayVersion", ApplicationVersion, Microsoft.Win32.RegistryValueKind.String)
AppKey.SetValue("DisplayIcon", ApplicationIconPath, Microsoft.Win32.RegistryValueKind.String)
AppKey.SetValue("Publisher", ApplicationPublisher, Microsoft.Win32.RegistryValueKind.String)
AppKey.SetValue("UninstallString", ApplicationUnInstallPath, Microsoft.Win32.RegistryValueKind.String)
AppKey.SetValue("UninstallPath", ApplicationUnInstallPath, Microsoft.Win32.RegistryValueKind.String)
AppKey.SetValue("InstallLocation", ApplicationInstallDirectory, Microsoft.Win32.RegistryValueKind.String)
End With