I am trying to get a list of the installed applications, i have a couple of scripts which do the trick in powershell or from the command window.
but, when i try to run a powerscript command or run a process, i get different data.
the CMD and PowerScript approach gets me 360 applications, but if i run from c# i get 215, and it outputs everything twice ??
simple power script method
Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion
Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion
the call to run a process
process = new Process();
process.StartInfo.FileName = "powershell.exe";
process.StartInfo.Arguments = @"-executionpolicy unrestricted -File D:\PS-Scripts\InstalledPrograms.ps1";
process.StartInfo.UseShellExecute = false;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.Verb = "runas";
process.OutputDataReceived += (s, e) => Console.WriteLine(e.Data);
process.Start();
process.BeginOutputReadLine();
am I missing something, why does the process call return different data, and also outputs everything twice.
Thanks