Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Rewrote the gow.vbs file to accept multiple commands like a true comm…

…and-line application. Added to the installer the capability to remove the older installations, added better debugging, added a feature which should allow Windows 7 installers to function and a couple more small tweaks.

Modified   bin/gow.vbs
* Main: Takes the first argument and looks for the command-line switches.  Prints out a message if there are errors.
* PrintUsage: Prints out the full program usage.
* Print: Prints out a command to the console.
* Version: Returns the version number of the application.
* ScriptPath: Returns the path of the gow.vbs VBS script.
* ExecutablesList: Now uses the ScriptPath method to get the folder path to list.

Modified   setup/Gow.nsi
* Added RequestExecutionLevel of 'admin' so that it works with Windows 7 installers.
* Set all show details commands to "hide" so that you can look at the commands if you wish.
* Added DetailPrint messages to most functions so that people will know what step caused an error if any come up.
* Configure: Now clears all errors so that the gow.bat file is written out correctly.
* Files: Installs all .dll files since there is one now.
* RemoveOldInstallation: New function that checks for previously installed Gow products and if it finds one it will prompt to uninstall the previous version.
* Shortcuts: Removed the antiquated Change Log message since this is now posted on GitHub.
* .onInit: Calls the RemoveOldInstallation function before the installer begins.
  • Loading branch information...
commit 2026078b54ea74dbbc97e2ec1f3f508c2a0df167 1 parent 932a8b5
Brent Matzelle authored
Showing with 96 additions and 28 deletions.
  1. +49 −22 bin/gow.vbs
  2. +47 −6 setup/Gow.nsi
71 bin/gow.vbs
View
@@ -1,18 +1,21 @@
'------------------------------------------------
-' Gow
-' Prints out all of the executables.
+' Gow - The lightweight alternative to Cygwin
+' Handles all tasks for the Gow project.
' Author: Brent R. Matzelle
'------------------------------------------------
Option Explicit
-'------------------------------------------------
' Adds a path to the environment variable.
-Sub ExecutablesList(path)
- Dim fileSys, folder, file, index, line
+Sub ExecutablesList()
+ Dim fileSys, folder, file, index, shell, line
line = " "
Set fileSys = CreateObject("Scripting.FileSystemObject")
- Set folder = filesys.GetFolder(path)
+
+ Set folder = filesys.GetFolder(ScriptPath())
+
+ Print "Available executables:"
+ Print ""
For Each file In folder.Files
If IsExecutable(file) Then
@@ -27,7 +30,6 @@ Sub ExecutablesList(path)
WScript.Echo Left(line, Len(line) - 2)
End Sub
-'------------------------------------------------
' Returns true if the file is an executable.
Function IsExecutable(file)
Dim result
@@ -44,30 +46,55 @@ Function IsExecutable(file)
IsExecutable = result
End Function
-'------------------------------------------------
' Main sub-routine
Sub Main()
If Wscript.Arguments.Count < 1 Then
- Call PrintUsage("")
+ PrintUsage
Exit Sub
End If
-
- WScript.Echo "Available executables:"
- WScript.Echo ""
- ExecutablesList(Wscript.Arguments(0))
+
+ Select Case Wscript.Arguments(0)
+ Case "-l", "--list"
+ Call ExecutablesList()
+ Case "-V", "--version"
+ Print("Gow " & Version())
+ Case "-h", "--help"
+ Call PrintUsage
+ Case Else
+ Print "UNKNOWN COMMAND: [" & WScript.Arguments(0) & "]"
+ Print ""
+ PrintUsage
+ End Select
End Sub
-'------------------------------------------------
-' Prints out the normal program usage parameters
-Sub PrintUsage(message)
- Dim usage
-
- If Len(message) > 0 Then
- usage = message & Chr(10)
- End If
+' Prints out a message.
+Sub Print(message)
+ Wscript.Echo message
+End Sub
- Wscript.Echo usage
+' Prints out the normal program usage parameters
+Sub PrintUsage()
+ Print "Gow " & Version() & " - The lightweight alternative to Cygwin"
+ Print "Usage: gow OPTION"
+ Print ""
+ Print "Options:"
+ Print " -l, --list Lists all executables"
+ Print " -V, --version Prints the version"
+ Print " -h, --help Show this message"
End Sub
+' Returns the path of the VBS script.
+Function ScriptPath
+ ScriptPath = Replace(WScript.ScriptFullName, "\" & WScript.ScriptName, "")
+End Function
+
+' Prints out the version of Gow.
+Function Version()
+ Version = "0.4.0"
+End Function
+
+
+'------------------------------------------------
' Start program here
Call Main()
+
53 setup/Gow.nsi
View
@@ -16,6 +16,7 @@
Name "${PRODUCT}"
SetCompressor zlib
BrandingText "${PRODUCT} ${VERSION} Installer - powered by NSIS"
+ RequestExecutionLevel admin
!include "MUI.nsh" ; Include Modern UI
@@ -48,8 +49,8 @@
!insertmacro MUI_LANGUAGE "English"
OutFile "${PRODUCT}-${VERSION}.exe" ; Installer file name
- ShowInstDetails nevershow
- ShowUninstDetails nevershow
+ ShowInstDetails hide
+ ShowUninstDetails hide
;--------------------------------
; Descriptions
@@ -85,13 +86,18 @@ SectionEnd
; Configures the installation
Function Configure
+ DetailPrint "Configuring the installation..."
+
StrCpy $R0 "cscript //NoLogo"
nsExec::Exec '$R0 "$INSTDIR\setup\PathSetup.vbs" --path-add "$INSTDIR\bin"'
- IfErrors done
+ SetOutPath $INSTDIR
+
+ ClearErrors
FileOpen $R1 "$INSTDIR\bin\gow.bat" w
+ IfErrors done
FileWrite $R1 "@echo off $\r$\n"
- FileWrite $R1 '$R0 "$INSTDIR\bin\gow.vbs" "$INSTDIR\bin" %1'
+ FileWrite $R1 '$R0 "$INSTDIR\bin\gow.vbs" %1'
FileClose $R1
done:
@@ -99,6 +105,8 @@ FunctionEnd
; Installs all files
Function Files
+ DetailPrint "Installing all files..."
+
; Copy Readme files
SetOutPath "$INSTDIR"
File "${SRC_DIR}\*.txt"
@@ -110,6 +118,7 @@ Function Files
; Executables
SetOutPath "$INSTDIR\bin"
File "${SRC_DIR}\bin\*.exe"
+ File "${SRC_DIR}\bin\*.dll"
File "${SRC_DIR}\bin\*.bat"
File "${SRC_DIR}\bin\*.vbs"
@@ -132,6 +141,8 @@ FunctionEnd
; Create the necessary registry entries
Function Registry
+ DetailPrint "Installing registry keys..."
+
; Write Registry settings for Add/Remove
WriteRegStr HKLM "SOFTWARE\${PRODUCT}" "" "$INSTDIR"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT}" \
@@ -142,13 +153,41 @@ FunctionEnd
; Add the Command Prompt Here entry
Function RegistryCommandPrompt
+ DetailPrint "Installing Command Prompt registry keys"
+
StrCpy $R0 'Folder\shell\Command Prompt Here ${PRODUCT}'
WriteRegStr HKCR $R0 "" "Command Prompt &Here"
WriteRegExpandStr HKCR "$R0\command" "" '"%SystemRoot%\system32\cmd.exe" /k cd /d "%1"'
FunctionEnd
+; Removes any old installations of Gow on the system.
+Function RemoveOldInstallation
+ DetailPrint "Checking for old Gow installation..."
+
+ ReadRegStr $R0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT}" \
+ "UninstallString"
+ StrCmp $R0 "" EndFunction 0
+
+ MessageBox MB_OKCANCEL \
+ "${PRODUCT} is already installed. $\n$\nClick OK to remove the \
+ previous version or Cancel to cancel this upgrade." \
+ IDOK uninstall
+ Abort
+
+uninstall:
+ ; Do not copy the uninstaller to a temp file
+ ExecWait '$R0 _?=$INSTDIR'
+
+ IfErrors 0 EndFunction
+ ; TODO: Perform error checking here
+
+ EndFunction:
+FunctionEnd
+
; Set the shortcuts
Function Shortcuts
+ DetailPrint "Installing Windows shortcuts..."
+
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
; License shortcuts
@@ -164,8 +203,6 @@ Function Shortcuts
; General shortcuts
SetOutPath "$SMPROGRAMS\$STARTMENU_FOLDER"
- CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\ChangeLog.lnk" \
- "$INSTDIR\ChangeLog.txt"
CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\ReadMe.lnk" \
"$INSTDIR\ReadMe.txt"
CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Uninstall ${PRODUCT} ${VERSION}.lnk" \
@@ -178,6 +215,10 @@ FunctionEnd
;--------------------------------
; Post installation methods
+Function .onInit
+ Call RemoveOldInstallation
+FunctionEnd
+
Function .onInstSuccess
Delete "$INSTDIR\Uninstall.exe" ; Delete old uninstaller first
WriteUninstaller "$INSTDIR\Uninstall.exe"
Please sign in to comment.
Something went wrong with that request. Please try again.