Reputation: 567
I'm trying to run a simple batch script to uninstall a windows update.
@echo off
REM uninstall windows update 2592687
wusa /uninstall /kb:2592687 /norestart
When I run this from a command line it works fine, however when run from a C# Console App
static void Main(string[] args)
{
string path = Path.GetFullPath("..\\..\\kbunins.bat");
ProcessStartInfo proc = new ProcessStartInfo(path);
Process.Start(proc);
}
I get a Installer encountered an error: 0x8000ffff Catastrophic failure error message I've tried googling that error message and couldn't find anything useful and I tried to run cmd.exe with the bat file as an argument and I have tried running the command directly and I got the same results.
Edit: I've built the application and run the installer as an administrator but the update still isn't uninstalled. I've also added in the File.Exists() bit and it finds the file.
What would cause this?
Upvotes: 1
Views: 955
Reputation: 11872
Try adding a check to see if your file exists before running. Something like this.
static void Main(string[] args)
{
string path = Path.GetFullPath(@"C:\Users\Me\Desktop\elloBatch.bat");
if(File.Exists(path))
{
ProcessStartInfo proc = new ProcessStartInfo(path);
Process.Start(proc);
}
else
{
Console.Write("File not at specified location.");
}
}
Also if possible I'd recommend you add your batch to your project (or drop it in the same location as your executable) and just reference it by file name.
Upvotes: 0
Reputation: 62246
Try to compile your app.
Go to bin folder. Right click on EXE
file and choose Run as Administrator.
If this works, just assign Administrator permission from your code (if you can do so).
Upvotes: 2