Skip to content

Commit

Permalink
tweak portable install; support renaming installation dir (#359)
Browse files Browse the repository at this point in the history
  • Loading branch information
mintty committed Nov 22, 2024
1 parent 440fbec commit a7b8792
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 8 additions & 2 deletions install-portable.bat
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
@echo off

echo Installing WSL Terminal Portable
echo Select target folder in popup dialog ...

set sel="Select folder to place installation of portable wsltty"

for /f "usebackq delims=" %%f in (`powershell "(new-object -COM Shell.Application).BrowseForFolder(0, '%sel%', 0, 0).self.path"`) do set f=%%f
Expand All @@ -14,15 +17,18 @@ if "%f%"=="" (
exit
)

rem call main installation
call install "%instdir%" "%instdir%" /P

rem create shortcut
cd /D "%instdir%"
set instpath=%instdir:~2%
cd /D "%instpath%"
set target=%%COMSPEC%%
set minttyargs=/C bin\mintty.exe --WSL= --icon=/wsl.ico --configdir=. -~
set bridgeargs= -
set wdir=%instpath%
rem set wdir=%instpath%
rem let mkshortcut set working directory to empty:
set wdir=.
set icon=%instpath%\wsl.ico
cscript /nologo mkshortcut.vbs "/name:WSL Terminal Portable"

4 changes: 4 additions & 0 deletions mkshortcut.vbs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,14 @@ rem wscript.echo "minttyargs: " & minttyargs
rem wscript.echo lnk.Arguments

rem Start in:
rem Working directory; Arguments.Named would take "/wdir:C:\..." parameters
rem wdir = Wscript.Arguments.Named("wdir")
rem Working directory; function ExpandEnvironmentStrings cannot pass empty
wdir = wshell.ExpandEnvironmentStrings("%wdir%")
if IsEmpty(wdir) then
lnk.WorkingDirectory = "%USERPROFILE%"
elseif wdir = "." then
lnk.WorkingDirectory = ""
else
lnk.WorkingDirectory = wdir
end if
Expand Down

0 comments on commit a7b8792

Please sign in to comment.