WS2008 subst in Logon script does not "stick"
Posted
by
Frans
on Server Fault
See other posts from Server Fault
or by Frans
Published on 2009-10-05T19:13:48Z
Indexed on
2012/04/09
11:33 UTC
Read the original article
Hit count: 297
I have a terminal server environment exclusively with Windows Server 2008.
My problem is that I need to "map" a drive letter to each users Temp folder. This is due to a legacy app that requries a separate Temp folder for each user but which does not understand %temp%.
So, just add "subst t: %temp%" to the logon script, right?
The problem is that, even though the command runs, the subst doesn't "stick" and the user doesn't get a T: drive.
Here is what I have tried;
The simplest version:
'Mapping a temp drive
Set WinShell = WScript.CreateObject("WScript.Shell")
WinShell.Run "subst T: %temp%", 2, True
That didn't work, so tried this for more debug information:
'Mapping a temp drive
Set WinShell = WScript.CreateObject("WScript.Shell")
Set procEnv = WinShell.Environment("Process")
wscript.echo(procEnv("TEMP"))
tempDir = procEnv("TEMP")
WinShell.Run "subst T: " & tempDir, 3, True
This shows me the correct temp path when the user logs in - but still no T: Drive. Decided to resort to brute force and put this in my login script:
'Mapping a temp drive
Set WinShell = WScript.CreateObject("WScript.Shell")
WinShell.Run "\\domain\sysvol\esl.hosted\scripts\tempdir.cmd", 3, True
where \domain\sysvol\esl.hosted\scripts\tempdir.cmd has this content:
echo on
subst t: %temp%
pause
When I log in with the above then the command window opens up and I can see the subst command being executed correctly, with the correct path. But still no T: drive.
I have tried running all of the above scripts outside of a login script and they always work perfectly - this problem only occurs when doing it from inside a login script.
I found a passing reference on an MSFN forum about a similar problem when the user is already logged on to another machine - but I have this problem even without being logged on to another machine.
Any suggestion on how to overcome this will be much appreciated.
© Server Fault or respective owner