我有一个包含在 exe 中的小型 PowerShell 脚本(使用 Quest Power GUI)。然后使用 mageUI.exe(即通过“ClickOnce”部署)将此 exe 部署到 UNC 路径。
现在,有一个命名空间可供我们使用:
这个命名空间允许我们确定该工具是否是网络部署的 + exe 的原始下载 URL/UNC。
所以我在我的 PowerShell 脚本中添加了以下几行(然后被 PowerGUI 编译成一个 exe)
# Line 1. Load the assembly
[System.Reflection.Assembly]::LoadWithPartialName("System.Deployment")
# Line 2. Utilise methods in the assembly. Below line will give either false or true, depending if the caller is deployed as a 'ClickOnce' app.
[System.Deployment.Application.ApplicationDeployment]::IsNetworkDeployed
Run Code Online (Sandbox Code Playgroud)
将此 exe 发布为“ClickOnce”应用程序(使用 mageUI.exe),将其放在网络共享上,然后从其他服务器(可以访问先前所说的共享)执行后,我仍然得到以下输出:
# Output of Line 1 (This signifies the assembly was loaded successfully)
GAC Version Location
--- …Run Code Online (Sandbox Code Playgroud)