Jump to content

Recommended Posts

Posted (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 by Xichael
  • Developers
Posted

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

Posted (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 by Xichael
  • 1 month later...
Posted (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 by Xichael
Posted

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

 

Posted (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 by Xichael

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
  • Recently Browsing   0 members

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