Skip to content

Instantly share code, notes, and snippets.

@runo280
Last active May 4, 2020 03:38
Show Gist options
  • Save runo280/81e40f8a647d37c0bff1b7fafa713d97 to your computer and use it in GitHub Desktop.
Save runo280/81e40f8a647d37c0bff1b7fafa713d97 to your computer and use it in GitHub Desktop.
Telegram Instance Runner [for Windows]
using System;
using System.Diagnostics;
using System.IO;
namespace Telegram
{
internal class Program
{
private static void Main(string[] args)
{
try
{
var path = Process.GetCurrentProcess().MainModule?.FileName;
Console.WriteLine($"path: {path}");
var dir = Path.GetDirectoryName(path);
Console.WriteLine($"dir: {dir}");
var name = Path.GetFileNameWithoutExtension(path);
if ("Telegram".Equals(name, StringComparison.OrdinalIgnoreCase)) return;
Console.WriteLine($"name: {name}");
var finalPath = $"{dir}\\t{name}";
Console.WriteLine($"finalPath: {finalPath}");
if (Directory.Exists(finalPath)) Directory.CreateDirectory(finalPath);
ProcessStartInfo tg = new ProcessStartInfo
{
FileName = $@"{dir}\\Telegram.exe",
Arguments = $@"-many -workdir {finalPath}"
};
Process.Start(tg);
}
catch (Exception e)
{
Console.WriteLine($"{e.Message}");
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment