In my console app that I am developing it displays the installed updates just fine and then it searches for available updates.
If there are no available updates it then needs to let the user know that there are no available updates and then to press any key to exit. If there are then it needs to download the updates and install (that code works as well btw)
I just need assistance in displaying a message like No New Updates Were Found
and `Press Any Key To Exit"
This is what I am tryin now but not working:
public static void UpdatesAvailable()
{
Console.WriteLine("\nChecking for new Updates.....");
UpdateSession UpdateSession = new UpdateSession();
IUpdateSearcher UpdateSearchResult = UpdateSession.CreateUpdateSearcher();
UpdateSearchResult.Online = true;//checks for updates online
ISearchResult SearchResults = UpdateSearchResult.Search("IsInstalled=0 AND IsPresent=0");
Console.WriteLine("\nAVAILABLE UPDATES");
if (SearchResults != null)
{
Console.WriteLine("No Updates Available");
Console.WriteLine("Press any key to exit...");
Console.ReadKey();
}
else
{
foreach (IUpdate x in SearchResults.Updates)
{
Console.WriteLine(x.Title);
}
}
}
I am testing on my PC and I know all my updates are installed so it does not find any new updates.
When I test on a other pc that needs updates it then displays a list of the new updates.
Thanks