I have a small PowerShell script wrapped in an exe (using Quest Power GUI). This exe is then deployed to a UNC path using mageUI.exe (i.e. through a 'ClickOnce' deployment).
Now, there is a namespace available to us:
This namespace allows us to figure out if the tool is network deployed + the originating download URL/UNC of the exe.
So I added the following lines in my PowerShell script (which was then compiled into an exe by PowerGUI)
# 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
After publishing this exe as a 'ClickOnce' application (using mageUI.exe), putting it on a network share, and then executing from some other server (which has access to previously said share), I still get the following output:
# Output of Line 1 (This signifies the assembly was loaded successfully)
GAC Version Location
--- ------- --------
True v4.0.30319 C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Deployment\v...
# Output of Line 2
False
Not sure what I'm doing wrong. The property IsNetworkDeployed
(Line 2) should have returned true.