Skip to content

Commit

Permalink
1.7.6: Add support for relative paths in scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
M1kerochip committed Jun 13, 2020
1 parent eefb575 commit b403a76
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 29 deletions.
4 changes: 2 additions & 2 deletions My Project/AssemblyInfo.vb
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' by using the '*' as shown below:
' <Assembly: AssemblyVersion("1.0.*")>

<Assembly: AssemblyVersion("1.7.5.0")>
<Assembly: AssemblyFileVersion("1.7.5.0")>
<Assembly: AssemblyVersion("1.7.6.0")>
<Assembly: AssemblyFileVersion("1.7.6.0")>
2 changes: 1 addition & 1 deletion Scripts_RelativeDirectories/_Notes.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Each bactch file has the path to the .exe hard coded, to a relative directory.
Each batch file has the path to the .exe hard coded, to a relative directory.

To use, decompress the required files to a folder on your HDD, and place the script files in the same folder.

Expand Down
17 changes: 0 additions & 17 deletions _Notes.txt

This file was deleted.

Binary file modified bin/Release/RunGreaseWeazel.exe
Binary file not shown.
34 changes: 25 additions & 9 deletions frmMain.vb
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,29 @@ Public Class frmMain
Replace(cmbDiskRevision.Text, " ", "_")
End Sub

Function ExecuteCommand(ByVal fileToRun As String, ByVal Arguments As String, ByVal WinState As Integer) As Boolean
Dim CMD As New Process
CMD.StartInfo.FileName = fileToRun
CMD.StartInfo.Arguments = Arguments
Select Case WinState
Case 0, 1 'Execute With normal cmd window (ie chkbox onscreen ticked or unticked)
CMD.StartInfo.UseShellExecute = True
CMD.StartInfo.WindowStyle = ProcessWindowStyle.Normal

Case 2 'Execute With hidden cmd window (ie chkbox onscreen is third state/half checked)
CMD.StartInfo.UseShellExecute = True
CMD.StartInfo.WindowStyle = ProcessWindowStyle.Minimized

Case 3 'Execute With no cmd window
CMD.StartInfo.UseShellExecute = False
CMD.StartInfo.CreateNoWindow = True
End Select

CMD.StartInfo.WorkingDirectory = IO.Path.GetDirectoryName(fileToRun)
'CMD.StartInfo.RedirectStandardInput = True
'CMD.StartInfo.RedirectStandardOutput = True
CMD.Start()
End Function
''' <summary>
''' Calls python.exe to run the gw.py script (Or run gw.exe directly in later versions)
''' </summary>
Expand Down Expand Up @@ -554,14 +577,7 @@ Public Class frmMain
End If

If oktorun Then
Dim inStartInfo As New ProcessStartInfo
inStartInfo.Arguments = fName
inStartInfo.FileName = txtExecuteScript.Text.Trim
inStartInfo.WindowStyle = ProcessWindowStyle.Normal
If chkExecuteScript.CheckState = CheckState.Indeterminate Then
inStartInfo.WindowStyle = ProcessWindowStyle.Minimized
End If
System.Diagnostics.Process.Start(inStartInfo)
ExecuteCommand(txtExecuteScript.Text.Trim, fName, chkExecuteScript.CheckState)
End If
End If
End If
Expand Down Expand Up @@ -731,7 +747,7 @@ Public Class frmMain
End Sub

Private Sub LinkLabelLaunchNow_LinkClicked(sender As Object, e As LinkLabelLinkClickedEventArgs) Handles LinkLabelLaunchNow.LinkClicked
System.Diagnostics.Process.Start(txtExecuteScript.Text.Trim, txtSaveLocation.Text.Trim + CreateFileName(False))
ExecuteCommand(txtExecuteScript.Text.Trim, txtSaveLocation.Text.Trim + CreateFileName(False), chkExecuteScript.CheckState)
End Sub

Private Sub ChkStartCyl_CheckedChanged(sender As Object, e As EventArgs) Handles ChkStartTrack.CheckedChanged
Expand Down

0 comments on commit b403a76

Please sign in to comment.