For example, this won't work if the elevated Powershell window is minimized:
WinActivate('Administrator: Windows PowerShell')
But on an standard unelevated window, this works fine:
WinActivate('Windows PowerShell')
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?
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'))
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.
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.
Sorry, I removed that line. Guess it served a purpose in the original example script.
Good to know about that WoW64 redirection stuff. Pretty esoteric stuff. Thanks!
No. That's just the example taken from: https://www.autoitscript.com/autoit3/docs/functions/FileExists.htm
I'm actually trying to launch the exe from a script using:
ShellExecute('tscon', '1 /dest:console', '', 'runas')
After hours of trying and failing to get it working, I finally found this issue.
Now that I know, I'll just make sure to run x64, but thought I should bring this to people's attention. It's a weird one.
The 64 bit version is able to access C:\Windows\System32\tscon.exe just fine, but 32 bit can't find it.
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>
Example()
Func Example()
; Create a constant variable in Local scope of the filepath that will be read/written to.
Local Const $sFilePath = "C:\Windows\System32\tscon.exe"
Local $iFileExists = FileExists($sFilePath)
; Display a message of whether the file exists or not.
If $iFileExists Then
MsgBox($MB_SYSTEMMODAL, "", "The file exists." & @CRLF & "FileExist returned: " & $iFileExists)
Else
MsgBox($MB_SYSTEMMODAL, "", "The file doesn't exist." & @CRLF & "FileExist returned: " & $iFileExists)
EndIf
EndFunc ;==>Example
Scripts run fine in a Remote Desktop session, until the RDP client window is minimized, which seems to pause the script.
I tried fixing it with this, to no avail. Anyone know how to get this working?
Thanks, guys. I've found a solution...
Instead of:
GUICtrlCreateButton("Cancel", 25, 130, 150, 50, $BS_DEFPUSHBUTTON)
I have to use:
GUICtrlCreateButton('Cancel', 25, 130, 150, 50)
GUICtrlSetState(-1, $GUI_FOCUS)