启动时运行c#程序
我刚刚制作了一个c#应用程序来组织我的桌面,如果我在终端上运行的话启动时运行c#程序,c#,bash,macos,automation,C#,Bash,Macos,Automation,我刚刚制作了一个c#应用程序来组织我的桌面,如果我在终端上运行的话 /Library/Frameworks/Mono.framework/Versions/Current/Commands/Mono Program.exe 我的程序正常运行,所以我想用Mac automator自动启动。bash命令是绿色的,但当我打开应用程序时,它会打开,然后立即停止。我是否做错了什么,或者是否有其他方式在启动时运行我的脚本。 这是我的c代码的主要部分,如果有帮助的话,我可以把它全部粘贴在这里 static v
/Library/Frameworks/Mono.framework/Versions/Current/Commands/Mono Program.exe
我的程序正常运行,所以我想用Mac automator自动启动。bash命令是绿色的,但当我打开应用程序时,它会打开,然后立即停止。我是否做错了什么,或者是否有其他方式在启动时运行我的脚本。
这是我的c代码的主要部分,如果有帮助的话,我可以把它全部粘贴在这里
static void Main(string[] args)
{
FileSystemWatcher fileSystemWatcher = new FileSystemWatcher();
fileSystemWatcher.Path = "/Users/user/Desktop/SortTheseFiles";
fileSystemWatcher.Created += FileChanged;
fileSystemWatcher.Changed += FileChanged;
fileSystemWatcher.Renamed += FileChanged;
fileSystemWatcher.EnableRaisingEvents = true;
FileSystemWatcher fileSystemWatcherDownloads = new FileSystemWatcher();
fileSystemWatcherDownloads.Path = "/Users/user/Downloads";
fileSystemWatcherDownloads.Created += DownloadsChanged;
fileSystemWatcherDownloads.Changed += DownloadsChanged;
fileSystemWatcherDownloads.Renamed += DownloadsChanged;
fileSystemWatcherDownloads.Deleted += DownloadsChanged;
fileSystemWatcherDownloads.EnableRaisingEvents = true;
Console.ReadKey();
}
我不知道如何使用Automator实现这一点,但您要求了另一种方法:
我制作了一个名为“我想从macOS开始”的工具。我发现,通过一些额外的挖掘,我可以使用apple脚本创建
/Library/LaunchAgents/
。这是我的密码
tell application "Terminal"
reopen
activate
do script "cd /Users/user/Desktop/CleanMyMac/CleanMyMac/bin/Release/netcoreapp3.1" in window 1
do script "dotnet CleanMyMac.dll" in window 1
end tell