diff --git a/bin/gow.vbs b/bin/gow.vbs index 1323f444..5cc21def 100644 --- a/bin/gow.vbs +++ b/bin/gow.vbs @@ -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() + diff --git a/setup/Gow.nsi b/setup/Gow.nsi index 5c0fd0ef..f8e77601 100644 --- a/setup/Gow.nsi +++ b/setup/Gow.nsi @@ -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"