Trying to get the user home

This commit is contained in:
FUH22860 2022-12-05 18:08:45 +01:00
parent 763de0a371
commit 9c05f3ac83
2 changed files with 22 additions and 11 deletions

View File

@ -1,15 +1,22 @@
using System.Diagnostics;
Process process = new Process();
string homePath;
if(Environment.OSVersion.Platform == PlatformID.Unix) {
homePath = Environment.GetEnvironmentVariable("HOME");
} else {
Console.WriteLine("This script doesn't support your operating system.");
}
ProcessStartInfo processStartInfo = new ProcessStartInfo();
processStartInfo.WindowStyle = ProcessWindowStyle.Hidden;
processStartInfo.FileName = @"ls";
processStartInfo.WorkingDirectory = @"/home/andre";
processStartInfo.Arguments = "--color";
processStartInfo.RedirectStandardOutput = false;
processStartInfo.RedirectStandardError = false;
processStartInfo.UseShellExecute = true;
Process process = new Process();
process.StartInfo = processStartInfo;
process.Start();
ProcessStartInfo processStartInfo = new ProcessStartInfo();
//processStartInfo.WindowStyle = ProcessWindowStyle.Hidden;
processStartInfo.FileName = @"yay";
//processStartInfo.WorkingDirectory = homePath;
//processStartInfo.Arguments = "--color";
processStartInfo.RedirectStandardOutput = false;
processStartInfo.RedirectStandardError = false;
processStartInfo.UseShellExecute = true;
process.StartInfo = processStartInfo;
process.Start();

View File

@ -3,6 +3,10 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<PublishSingleFile>true</PublishSingleFile>
<SelfContained>true</SelfContained>
<RuntimeIdentifier>linux-x64</RuntimeIdentifier>
<PublishReadyToRun>true</PublishReadyToRun>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>