Commits

Anonymous committed 5b2634c

Rewrote the gow.vbs file to accept multiple commands like a true command-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.

  • Participants
  • Parent commits 394d50b

Comments (0)

Files changed (2)

 '------------------------------------------------
-' 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
   WScript.Echo Left(line, Len(line) - 2)
 End Sub
 
-'------------------------------------------------
 ' Returns true if the file is an executable. 
 Function IsExecutable(file)
   Dim result
   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
-
-  Wscript.Echo usage
+' Prints out a message.  
+Sub Print(message)
+  Wscript.Echo message
 End Sub
 
+' 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()
+

File setup/Gow.nsi

   Name "${PRODUCT}"
   SetCompressor zlib
   BrandingText "${PRODUCT} ${VERSION} Installer - powered by NSIS"
+  RequestExecutionLevel admin
 
   !include "MUI.nsh" ; Include Modern UI
 
   !insertmacro MUI_LANGUAGE "English"
 
   OutFile "${PRODUCT}-${VERSION}.exe" ; Installer file name
-  ShowInstDetails nevershow
-  ShowUninstDetails nevershow
+  ShowInstDetails hide
+  ShowUninstDetails hide
 
 ;--------------------------------
 ; Descriptions
 
 ; Configures the installation
 Function Configure
+  DetailPrint "Configuring the installation..."
+
   StrCpy $R0 "cscript //NoLogo"
   nsExec::Exec '$R0 "$INSTDIR\setup\PathSetup.vbs" --path-add "$INSTDIR\bin"'
 
+  SetOutPath $INSTDIR
+
+  ClearErrors
+  FileOpen $R1 "$INSTDIR\bin\gow.bat" w
   IfErrors done
-  FileOpen $R1 "$INSTDIR\bin\gow.bat" w
   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:
 
 ; Installs all files
 Function Files
+  DetailPrint "Installing all files..."
+
   ; Copy Readme files
   SetOutPath "$INSTDIR"
   File "${SRC_DIR}\*.txt"
   ; Executables
   SetOutPath "$INSTDIR\bin"
   File "${SRC_DIR}\bin\*.exe"
+  File "${SRC_DIR}\bin\*.dll"
   File "${SRC_DIR}\bin\*.bat"
   File "${SRC_DIR}\bin\*.vbs"
 
 
 ; 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}" \
 
 ; 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
 
   ; 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" \
 ;--------------------------------
 ; Post installation methods
 
+Function .onInit
+  Call RemoveOldInstallation
+FunctionEnd
+
 Function .onInstSuccess
   Delete "$INSTDIR\Uninstall.exe" ; Delete old uninstaller first
   WriteUninstaller "$INSTDIR\Uninstall.exe"