%sessionname% returns incorrect session name
- by Samuel Walker
I have a virtualised Windows XP SP3 machine, which I am connecting to over Remote Desktop.
One of my scripts needs to use the %sessionname% variable. However this returns incorrect information.
C:\>%sessionname%
constantly returns RDP-Tcp#5, instead of the value for the currently connected session (RDP-Tcp#35 or similar), as shown in Task Manager
This causes my scripts to contain incorrect information. What can I do to resolve this?
Edit Further Information: A restart appears to solve the problem for the first connection, but then subsequent connections have the numbers fall out of sync again.