visual studio - How to get a list of AppV virtual processes using C# -


i trying list of virtual processes started microsoft appv using c#.

i tried using powershell in c# error:

system.management.automation.commandnotfoundexception: 'the 'get-appvvirtualprocess' command found in module 'appvclient', module not loaded. more information, run 'import-module appvclient'.'

the weird thing if use powershell command line, works fine , lists virtual processes.

so in c# did a:

ps.commands.addcommand("get-command"); 

and shows get-appvvirtualprocess listed command:

the result:

function get-appvvirtualprocess 1.0.0.0 a

i tried loading module in c# manually using:

initialsessionstate initial = initialsessionstate.createdefault(); initial.importpsmodule(new string[] {@"c:\program files\microsoft application virtualization\client\appvclient\appvclient.psd1" }); 

and

ps.commands.addcommand("import-module").addargument("appvclient"); 

but still gives me same error mentioned above.

the code in c# looks this:

public static void powershellcommand() {     collection<psobject> result;           using (runspace myrunspace = runspacefactory.createrunspace())     {         initialsessionstate initial = initialsessionstate.createdefault();         initial.importpsmodule(new string[] {@"c:\program files\microsoft application virtualization\client\appvclient\appvclient.psd1" });         runspace runspace = runspacefactory.createrunspace(initial);         runspace.open();         powershell ps = powershell.create();         ps.runspace = runspace;         ps.commands.addcommand("import-module").addargument("appvclient");          ps.commands.addcommand("get-appvvirtualprocess");          result = ps.invoke();             var builder = new stringbuilder();             foreach (psobject psobject in result)             {                  builder.append(psobject.tostring() + "\n");                 builder.tostring();              }              console.writeline("virtual process: {0}", builder.tostring());         }  } 

instead of runspace, tried same error:

public static void p() {     using (var powershell = powershell.create())     {         powershell.addcommand("get-appvvirtualprocess");          powershell.invoke();     } } 

you try iterate through running process, , find loaded either appventsubsystems32.dll or appventsubsystems64.dll.

you can read more here: https://blogs.msdn.microsoft.com/gladiator/2014/09/04/app-v-5-on-application-launch/


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -