Closed zoredache closed 4 years ago
Good call - probably best doing this in the windows .bat
script before launching wsl.exe
Well I was thinking more in the shortcut creation.
def create_shortcut(link_file, executable, arguments=None, comment=None, icon_file=None):
windows_lnk = get_windows_path_from_wsl_path(link_file)
powershell_cmd = "powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile "
powershell_cmd += "-Command '"
powershell_cmd += '$ws = New-Object -ComObject WScript.Shell; '
powershell_cmd += '$s = $ws.CreateShortcut("%s");' % windows_lnk
powershell_cmd += '$s.TargetPath = "%s";' % executable
powershell_cmd += '$s.Arguments = "%s";' % arguments.replace('"', '`"')
powershell_cmd += '$s.Description = "%s";' % comment
+ powershell_cmd += '$s.WorkingDirectory = "%USERPROFILE%";'
powershell_cmd += '$s.IconLocation = "%s";' % icon_file
powershell_cmd += '$s.Save()'
BTW, your powershell command might be less complicated if you used the powershell -EncodedCommand
. I suspect getting all the escaping right is a bit tricky.
Ha yeah yeah it's not hard to tell this is about the only line of powershell I have ever written. WIll look about adding it in there it makes sense to me.
Should possibly also consider Path from the .desktop
specification - that would just be discarded at the moment (though that would almost definitely make more sense on the .sh
side).
Pushed in a change there to default to %USERPROFILE
as above, but to also allow Path
from the desktop specification to take precedence.
When I start a terminal I am dropped into
/mnt/c/WINDOWS/system32
. This happens because Windows will defaultStart in
to be whatever the path is for the program being launched so on my systemC:\WINDOWS\system32\wscript.exe
. WSL when launched will try to preserve your working directory.It seems to me that is very unlikely people will want/need a default working directory in the system32 folder.