Skip to content

Commit

Permalink
feat: fix on args on run methods and nex profiles
Browse files Browse the repository at this point in the history
  • Loading branch information
minkostaev committed Dec 30, 2022
1 parent 4cefaa6 commit 7ce4c2d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dotnet-desktop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ jobs:
cd ${{ env.Proj_Name }}
#dotnet publish ShortcutsGrid.csproj /p:PublishProfile="Win System"
#copy "bin\Win System\net6.0-windows\publish\win-x64\Win System.exe" ..\\${{ env.Test_Proj_Dir }}\\TestResults
$exes = "Win System","Win Admin","Office","Utils","Browsers","Connections","Disk Tools","Audio","Image","Video","Hardware"
$exes = "Win System","Win Admin","Office","Utils","Browsers","Connections","Disk Tools","Audio","Image","Video","Hardware","Virtual Machines","Programming","Games"
foreach ($name in $exes){dotnet publish ShortcutsGrid.csproj /p:PublishProfile="$name"}
foreach ($name in $exes){copy "bin\$name\net6.0-windows\publish\win-x64\$name.exe" ..\\${{ env.Test_Proj_Dir }}\\TestResults}
Expand Down
30 changes: 27 additions & 3 deletions ShortcutsGrid/Services/Run/RunProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Windows.Documents;

public static class RunProcess
{
Expand All @@ -27,8 +30,29 @@ public static string Run(string commandOrPath, bool admin = false)
try
{
string[] cmdAndArgs = commandOrPath.Split(' ');
string args = commandOrPath.Remove(0, cmdAndArgs[0].Length);
ProcessStart(cmdAndArgs[0], admin, args);
string processCommandOrPath = string.Empty;
string args = string.Empty;
if (commandOrPath.Contains('\\'))
{
var pathStructure = cmdAndArgs.ToList();
for (int i = cmdAndArgs.Length - 1; i > 0; i--)
{
pathStructure.RemoveAt(i);
var fileOrFolder = String.Join(" ", pathStructure.ToArray());
if (File.Exists(fileOrFolder))//to do case for folder if needed
{
processCommandOrPath = fileOrFolder;
args = commandOrPath.Replace(processCommandOrPath, "");
break;
}
}
}
else
{
args = commandOrPath.Remove(0, cmdAndArgs[0].Length);
processCommandOrPath = cmdAndArgs[0];
}
ProcessStart(processCommandOrPath, admin, args);
return string.Empty;
}
catch (Exception ex) { return ex.Message; }
Expand All @@ -39,7 +63,7 @@ private static void ProcessStart(string commandOrPath, bool admin, string args =
{
Process process = new Process();
process.StartInfo.UseShellExecute = true;
//todo
//to do
///process.StartInfo.WorkingDirectory = "c:\\";
process.StartInfo.FileName = commandOrPath;
process.StartInfo.Arguments = args;
Expand Down
2 changes: 1 addition & 1 deletion ShortcutsGrid/ShortcutsGrid.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
<RuntimeIdentifiers>win-x64</RuntimeIdentifiers>
<ApplicationIcon>Resources\hardware-128.ico</ApplicationIcon>
<ApplicationIcon>Resources\games-128.ico</ApplicationIcon>
<AssemblyVersion>1.2.2.1</AssemblyVersion>
<FileVersion>1.2.2.1</FileVersion>
<VersionPrefix>1.2.2</VersionPrefix>
Expand Down

0 comments on commit 7ce4c2d

Please sign in to comment.