Xichael Posted March 17, 2017 Posted March 17, 2017 In CMD, echo %SESSIONNAME% works fine, but AutoIt's EnvGet("SESSIONNAME") produces nothing. Anyone know how to get this working?
Developers Jos Posted March 17, 2017 Developers Posted March 17, 2017 Works fine here. Have you checked to see what the result is for "echo %SESSIONNAME% " when running the 32 cmd version? ( %windir%\SysWoW64\cmd.exe ) Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Gianni Posted March 17, 2017 Posted March 17, 2017 it works here (win7 x64 AutoIt v 3.3.14.2) Local $sValue = EnvGet("SESSIONNAME") MsgBox(0, "EnvGet", $sValue) Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....
Xichael Posted March 17, 2017 Author Posted March 17, 2017 (edited) On 3/17/2017 at 10:53 AM, Jos said: Works fine here. Have you checked to see what the result is for "echo %SESSIONNAME% " when running the 32 cmd version? ( %windir%\SysWoW64\cmd.exe ) Yes, that's working. Edited May 6, 2017 by Xichael
Developers Jos Posted March 17, 2017 Developers Posted March 17, 2017 What is the output of this script when ran in SciTE: ? #include <AutoItConstants.au3> Local $iPID = Run(@ComSpec & ' /C set ',"", @SW_HIDE, $STDOUT_CHILD) ProcessWaitClose($iPID) Local $sOutput = StdoutRead($iPID) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $sOutput = ' & $sOutput & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Xichael Posted March 17, 2017 Author Posted March 17, 2017 (edited) ... Edited May 6, 2017 by Xichael
Xichael Posted March 18, 2017 Author Posted March 18, 2017 (edited) It's actually working if I launch the script from Cmd or the Run window, but if I launch with a double-click from Explorer, EnvGet("SESSIONNAME") is empty. On 3/17/2017 at 11:05 AM, Jos said: What is the output of this script when ran in SciTE: ? #include <AutoItConstants.au3> Local $iPID = Run(@ComSpec & ' /C set ',"", @SW_HIDE, $STDOUT_CHILD) ProcessWaitClose($iPID) Local $sOutput = StdoutRead($iPID) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $sOutput = ' & $sOutput & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console Similar situation here; if I launch SciTE from the Explorer context menu and F5 to run your script, no SESSIONNAME in the console, but if I launch SciTE from the start menu and run it, it's there. Edited May 6, 2017 by Xichael
Xichael Posted May 6, 2017 Author Posted May 6, 2017 (edited) Still struggling with this one, if anyone can help. Quick recap: Works fine if I Win+R > C:\Path\To\Script.au3, but fails if I double-click from Explorer (both 32 and 64 bit). MsgBox('','',EnvGet('sessionname')) Edited May 6, 2017 by Xichael
Subz Posted May 6, 2017 Posted May 6, 2017 It appears to be using System Session rather than the User Session, you probably could use: ExpandEnvironmentStringsForUserhttps://msdn.microsoft.com/en-us/library/windows/desktop/bb762275(v=vs.85).aspx However for me its easier just to get the info from registry for example: Func _RegSessionName() Local $i = 1, $sRegRoot = "HKCU\Volatile Environment", $sRegKey, $sRegVal = "" While 1 $sRegKey = RegEnumKey($sRegRoot, $i) If @error Then ExitLoop $sRegVal = RegRead($sRegRoot & "\" & $sRegKey, "SessionName") If $sRegVal <> "" Then Return $sRegVal $i += 1 WEnd Return "" EndFunc
Xichael Posted May 6, 2017 Author Posted May 6, 2017 (edited) Thanks, that works great. Wondering though, when would SessionName ever not be at key 1? It'd be nice if I could just use this: RegRead('HKCU\Volatile Environment\1', 'SessionName') Also, is this System Session vs User Session situation with EnvGet a bug? Edited May 6, 2017 by Xichael
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now