Skip to content

Commit

Permalink
Fixed the launcher so that it can now delete itself as well as Wordler
Browse files Browse the repository at this point in the history
  • Loading branch information
vesk4000 committed Mar 18, 2022
1 parent 0489bda commit 19b933b
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 12 deletions.
1 change: 1 addition & 0 deletions Source/CLI/Commands/SolveCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public override int Execute([NotNull] CommandContext context, [NotNull] Settings
if(settings.PowerShellCommands != "")
{
var psc = new ProcessStartInfo("powershell.exe", " -Command { " + settings.PowerShellCommands.Replace("@ID", Process.GetCurrentProcess().Id.ToString() + " }"));
psc.WorkingDirectory = Directory.GetParent(Directory.GetCurrentDirectory()).FullName;
Process.Start(psc);
}

Expand Down
26 changes: 26 additions & 0 deletions Wordler Launcher/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"version": "0.2.0",
"configurations": [
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/bin/Debug/net5.0/Wordler Launcher.dll",
"args": [],
"cwd": "${workspaceFolder}",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "internalConsole",
"stopAtEntry": false
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach"
}
]
}
41 changes: 41 additions & 0 deletions Wordler Launcher/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/Wordler Launcher.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "publish",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/Wordler Launcher.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "watch",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"--project",
"${workspaceFolder}/Wordler Launcher.csproj"
],
"problemMatcher": "$msCompile"
}
]
}
6 changes: 4 additions & 2 deletions Wordler Launcher/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ class Program
static void Main(string[] args)
{
Process wordler = new Process();
wordler.StartInfo.FileName = Directory.GetCurrentDirectory() + "\\Wordler.exe";
wordler.StartInfo.FileName = Directory.GetCurrentDirectory() + "\\Wordler\\Wordler.exe";
wordler.StartInfo.UseShellExecute = false;
wordler.StartInfo.CreateNoWindow = true;
wordler.StartInfo.Arguments = "--tl 15 --ps \" Wait-Process -Id @ID; $directorypath = (Get-Item .).FullName; $path = $directorypath + '\\Wordlerer\\';If (!(test-path $path)) { mkdir $path }; Remove-Item $directorypath; \"";
wordler.StartInfo.Arguments = File.ReadAllText(Directory.GetCurrentDirectory() + "\\Wordler\\launcher_args.txt");
wordler.StartInfo.WorkingDirectory = Directory.GetCurrentDirectory() + "\\Wordler";
Console.WriteLine($"{wordler.StartInfo.FileName} {wordler.StartInfo.Arguments}");
wordler.Start();
return;
}
Expand Down
1 change: 1 addition & 0 deletions launcher_args.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--tl 5 --ps " Wait-Process -Id @ID; $directorypath = (Get-Item .).FullName; $path = $directorypath + '\Wordler'; Remove-Item $path -Recurse -Force "
20 changes: 10 additions & 10 deletions run.ps1
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
$directorypath = (Get-Item .).FullName

$path = $directorypath + '\Wordler\'
If (!(test-path $path)) { mkdir $path }
#$path = $directorypath + '\Wordler\'
#If (!(test-path $path)) { mkdir $path }

$url = 'https://github.com/vesk4000/Wordler/releases/download/v1.2.1/wordlist.txt'
$path_to_file = $directorypath + '\Wordler\wordlist.txt'
Invoke-WebRequest $url -OutFile $path_to_file
#$url = 'https://github.com/vesk4000/Wordler/releases/download/v1.2.1/wordlist.txt'
#$path_to_file = $directorypath + '\Wordler\wordlist.txt'
#Invoke-WebRequest $url -OutFile $path_to_file

$url = 'https://github.com/vesk4000/Wordler/releases/download/v1.2.1/Wordler.exe'
$path_to_file = $directorypath + '\Wordler\Wordler.exe'
$directory_to_file = $directorypath + '\Wordler\'
Invoke-WebRequest $url -OutFile $path_to_file
#$url = 'https://github.com/vesk4000/Wordler/releases/download/v1.2.1/Wordler.exe'
#$path_to_file = $directorypath + '\Wordler\Wordler.exe'
#$directory_to_file = $directorypath + '\Wordler\'
#Invoke-WebRequest $url -OutFile $path_to_file

Start-Process -FilePath 'Wordler\Wordler Launcher.exe' -WorkingDirectory $directory_to_file
Start-Process -FilePath 'Wordler\Wordler Launcher.exe'# -WorkingDirectory $directory_to_file

0 comments on commit 19b933b

Please sign in to comment.