如何为安装和部署项目设置InstallLocation [英] How to set InstallLocation for Setup and deployement Project
问题描述
如何为安装和部署项目设置或获取InstallLocation,因为当我在下面的片段中写下它的返回空白
Dim registry_key 作为 字符串 = SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Uninstall
使用键作为 Microsoft.Win32.RegistryKey = Registry.LocalMachine.OpenSubKey(registry_key)
对于 每个 subkey_name As String 在 key.GetSubKeyNames()
使用子键作为 RegistryKey = key.OpenSubKey(subkey_name)
如果 subkey.GetValue( DisplayName )= 应用程序名称 然后
返回 subkey.GetValue( InstallLocation)
结束 如果
结束 使用
下一步
subkey.GetValue( InstallLocation)
对某些应用程序可以正常工作,有些则不行。
但我需要通过提供MSI请求的应用程序名称来读取位置e帮助我(whew)
你可以使用这样的执行装配位置:
< span class =code-keyword>公共 共享 功能 GetAssemblyDirectory()作为 字符串
返回 (Path.GetDirectoryName( New Uri(System.Reflection.Assembly.GetExecutingAssembly()。CodeBase).LocalPath))
结束 功能
In另外,据我所知,您在安装项目中使用自定义操作。
您可以将安装程序属性值传递给CustomActionData字段中的自定义操作。
例如:
/ AllUsers = [ALLUSERS] / ProductName = [ProductName] / ProductLanguage = [ProductLang uage]
在自定义操作中,您可以使用Context对象使用这些值:
Dim productName 作为 字符串 = Context.Parameters ( ProductName)
Dim productLanguage 作为 字符串 = Context.Parameters( ProductLanguage)
查看标准安装程序的完整列表属性
http://msdn.microsoft .com / zh-CN / library / aa370905(v = vs.85).aspx [ ^ ]
访问此处了解....
如何参考-c-users-public-directory-programically-in-c-sharp [ ^ ]
How to set or get InstallLocation for Setup and deployement Project because while i write below snippet its returns empty
Dim registry_key As String = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
Using key As Microsoft.Win32.RegistryKey = Registry.LocalMachine.OpenSubKey(registry_key)
For Each subkey_name As String In key.GetSubKeyNames()
Using subkey As RegistryKey = key.OpenSubKey(subkey_name)
If subkey.GetValue("DisplayName") = "Application Name" Then
Return subkey.GetValue("InstallLocation")
End If
End Using
Next
subkey.GetValue("InstallLocation")
Will work fine for some Application and for some its not .
but i need to read location by providing application name of MSI please help me (whew)
You may use the executing assembly location like this:
Public Shared Function GetAssemblyDirectory() As String Return (Path.GetDirectoryName(New Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).LocalPath)) End Function
In addition, as I understand, you use custom actions in the setup project.
You may pass installer property values to custom actions in CustomActionData field.
For example:
/AllUsers=[ALLUSERS] /ProductName=[ProductName] /ProductLanguage=[ProductLanguage]
In the custom action you may use the values using the Context object like this:
Dim productName As String = Context.Parameters("ProductName") Dim productLanguage As String = Context.Parameters("ProductLanguage")
See a complete list of standard installer properties at
http://msdn.microsoft.com/en-us/library/aa370905(v=vs.85).aspx[^]
visit here to understand....
how-to-reference-the-c-users-public-directory-programmatically-in-c-sharp[^]
这篇关于如何为安装和部署项目设置InstallLocation的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!