From eec84b05387d5408bd664a0a2d36873679019593 Mon Sep 17 00:00:00 2001 From: Pat Thoyts Date: Fri, 18 Feb 2011 08:38:44 +0000 Subject: [PATCH] issue #535: support UNC paths for the "Git Bash Here" explorer menu item. As pointed out in issue #535 the explorer integration menu item does not open UNC paths. This patch creates a temporary shortcut item with the target path set before it executes the bash program and solves this issue. Suggested-by: Alex Ivanov Signed-off-by: Pat Thoyts --- share/WinGit/Git Bash.vbs | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) rewrite share/WinGit/Git Bash.vbs (99%) diff --git a/share/WinGit/Git Bash.vbs b/share/WinGit/Git Bash.vbs dissimilarity index 99% index 365189b4..c95fed13 100644 --- a/share/WinGit/Git Bash.vbs +++ b/share/WinGit/Git Bash.vbs @@ -1,10 +1,20 @@ -' If there is an argument, use it as the directory to change to. -If WScript.Arguments.Length=1 Then - Set WshObj = CreateObject("WScript.Shell") - WshObj.CurrentDirectory = WScript.Arguments(0) -End If - -' Launch the shortcut in the current directory which has the same -' base name as this script. -Set AppObj = CreateObject("Shell.Application") -AppObj.ShellExecute(Replace(WScript.ScriptFullName, ".vbs", ".lnk")) +Option Explicit + +Dim shell : Set shell = CreateObject("WScript.Shell") +Dim fso : Set fso = CreateObject("Scripting.FileSystemObject") +Dim gitdir : gitdir = Left(WScript.ScriptFullName,InStrRev(WScript.ScriptFullName,"\")) +Dim bash : bash = fso.BuildPath(gitdir, "bin\sh.exe") +Dim temp : temp = fso.GetSpecialFolder(2) ' Temporary folder +Dim linkfile : linkfile = fso.BuildPath(temp, fso.GetTempName() & ".lnk") + +Dim link : Set link = shell.CreateShortCut(linkfile) +link.TargetPath = bash +link.Arguments = "--login -i" +link.WindowStyle = 1 +If WScript.Arguments.Length > 0 Then link.WorkingDirectory = WScript.Arguments(0) +link.Save + +Dim app : Set app = CreateObject("Shell.Application") +app.ShellExecute linkfile +WScript.Sleep 500 +fso.DeleteFile linkfile -- 2.11.4.GIT