Jump to content

Unable to EnvGet("SESSIONNAME")


Recommended Posts

  • Developers

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.
  :)

Link to comment
Share on other sites

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 by Xichael
Link to comment
Share on other sites

  • Developers

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.
  :)

Link to comment
Share on other sites

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 by Xichael
Link to comment
Share on other sites

  • 1 month later...

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 by Xichael
Link to comment
Share on other sites

It appears to be using System Session rather than the User Session, you probably could use:

ExpandEnvironmentStringsForUser
https://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

 

Link to comment
Share on other sites

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 by Xichael
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...