No session required on Windows 11
ethouris opened this issue · 0 comments
ethouris commented
I found this script here and it was kinda outdated on Windows 11. The location for the currently selected desktop is to be read by
RegRead, CurrentDesktopId, HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VirtualDesktops, CurrentVirtualDesktop
I can see the version here is fixed, but this is kinda incorrect - the condition to check for SessionId
only makes sense if you want to extract the key dependent on the SessionId - while the latest verison here reads the key with the path as above under this condition. Before looking here I fixed it myself this way (just to show you an example):
IdLength := 32
SessionId := getSessionId()
if (SessionId) {
RegRead, CurrentDesktopId, HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\SessionInfo\%SessionId%\VirtualDesktops, CurrentVirtualDesktop
if (CurrentDesktopId) {
IdLength := StrLen(CurrentDesktopId)
}
}
if !CurrentDesktopId {
RegRead, CurrentDesktopId, HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VirtualDesktops, CurrentVirtualDesktop
if (CurrentDesktopId) {
IdLength := StrLen(CurrentDesktopId)
}
}
(The problem with your version is that when there weren't SessionId
, this script won't work, even though SessionId
is not needed)