Temporary Folder in "Git Bash.vbs" always resolves to C:\Windows

539 views
Skip to first unread message

Andrew Rollins

unread,
Oct 12, 2011, 2:52:27 PM10/12/11
to msysGit
When using the version installed from Git-1.7.7-preview20111012.exe,
there is this line in "Git Bash.vbs":

linkfile = fso.BuildPath(fso.GetSpecialFolder(TemporaryFolder), "Git
Bash.lnk")

For me, fso.GetSpecialFolder(TemporaryFolder) always resolves to C:
\Windows, whether I run "Git Bash Here" or run the script directly.
The script can't write its link to C:\Windows, so it fails. I had to
replace that line with this:

linkfile = fso.BuildPath(shell.ExpandEnvironmentStrings("%TMP%"), "Git
Bash.lnk")

This correctly expands to the temporary folder for my user account.
I'm not sure if others are having this problem, but this will fix it.

Johannes Schindelin

unread,
Oct 12, 2011, 4:53:07 PM10/12/11
to Andrew Rollins, msysGit
Hi,

Could you add something like this instead (please correct the syntax, I
haven't been a Visual Basic programmer in 10 years):

tmpdir = fso.BuildPath(fso.GetSpecialFolder(TemporaryFolder))
if !tmpdir.isWritable
tmpdir = fso.BuildPath(shell.ExpandEnvironmentStrings("%TMP%"))
linkfile = fso.BuildPath(tmpdir, "Git Bash.lnk")

This way, existing setups where nothing was broken will not change their
behavior.

Ciao,
Johannes

Pat Thoyts

unread,
Oct 12, 2011, 5:51:42 PM10/12/11
to Johannes Schindelin, Andrew Rollins, msysGit
On 12 October 2011 21:53, Johannes Schindelin

The problem is that nothing imported the enum symbols so it doesn't
actually understand 'TemporaryFolder'. If you use the documented value
of 2 then it works. According to the documentation for
GetSpecialFolder, passing in 2 will return the value of TMP anyway. As
an example create a file test.vbs with:
Dim oFSO : Set oFSO = CreateObject("Scripting.FileSystemObject")
WScript.Echo oFSO.GetSpecialFolder(2)
and run it using cscript test.vbs. If you use the word
'TemporaryFolder' then it treats it as 0 which is the value to obtain
the windows folder.

Andrew Rollins

unread,
Oct 12, 2011, 7:05:47 PM10/12/11
to Pat Thoyts, Johannes Schindelin, msysGit
Pat, good find. The script should be updated to import the enum properly. I'm not a VB guy, so does anyone know how to do that?

Pat Thoyts

unread,
Oct 12, 2011, 8:14:15 PM10/12/11
to Andrew Rollins, Johannes Schindelin, msysGit
On 13 October 2011 00:05, Andrew Rollins <and...@andrewrollins.com> wrote:
> Pat, good find. The script should be updated to import the enum properly.
> I'm not a VB guy, so does anyone know how to do that?
>
The documentation examples just declare
Const TemporaryFolder = 2
within the script. So we can simply follow suit. I believe you can do
the imports from typelibraries only if using the xml based wsf files
which let you import things using xml declarations. Plain vbs cannot
manage it.
I just reset to Windows 8 so a patch will have to wait till tomorrow
at least from me.

Pat Thoyts

unread,
Oct 13, 2011, 5:22:05 AM10/13/11
to Andrew Rollins, Johannes Schindelin, msysGit

Johannes Schindelin

unread,
Oct 13, 2011, 11:52:36 AM10/13/11
to Pat Thoyts, Andrew Rollins, msysGit
Hi Pat,

Cool, thanks!

Ciao,
Dscho

Reply all
Reply to author
Forward
0 new messages