I am trying to use this program, but I would like to be able to pass a parameter where:
DeleteOnReboot(@"C:\test.txt");
"C:\Text" is
So I could call consoleapp.exe /C:\test2.exe
So I would have a variable in code e.g.
DeleteOnReboot(@"%VARIABLE%");
Full Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
namespace ConsoleApplication1
{
class Program
{
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
public static extern bool MoveFileEx(string
lpExistingFileName, string lpNewFileName, int dwFlags);
public const int MOVEFILE_DELAY_UNTIL_REBOOT = 0x4;
public static void DeleteOnReboot(string filename)
{
if (!MoveFileEx(filename, null,
MOVEFILE_DELAY_UNTIL_REBOOT))
Console.WriteLine("Failed");
}
static void Main(string[] args)
{
DeleteOnReboot(@"C:\test.txt");
Console.ReadKey();
}
}
}