#3868 closed Bug (Fixed)
Directive #RequireAdmin can suppress ConsoleWrite/ConsoleWriteError output.
Reported by: | OJBakker | Owned by: | Jos |
---|---|---|---|
Milestone: | Component: | SciTE4AutoIt | |
Version: | Other | Severity: | None |
Keywords: | Cc: |
Description
When this script is run in Scite:
UAC-elevation prompt appears
The IsAdmin in the script reports True, so the scripts runs elevated.
The log reports nothing about elevating the script.
The ConsoleWrite/ConsoleWriteErrror messages do nog appear in the log.
Script:
#RequireAdmin ; This script requires full Administrative rights Main() Exit Func Main() If IsAdmin() then MsgBox(Default, Default, "Admin is true") ConsoleWrite("Normal output" & @CRLF) ConsoleWriteError("Error output" & @CRLF) EndFunc
Scite output:
>"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "C:\Programs\AutoIt-Bugs\TestAdmin.au3" /UserParams +>10:52:13 Starting AutoIt3Wrapper (21.316.1639.1) from:SciTE.exe (4.4.6.0) Keyboard:00020409 OS:WIN_10/2009 CPU:X64 OS:X64 Environment(Language:0413) CodePage:0 utf8.auto.check:4 +> SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE UserDir => C:\Users\BakkerSSDpc\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper SCITE_USERHOME => C:\Users\BakkerSSDpc\AppData\Local\AutoIt v3\SciTE >Running AU3Check (3.3.16.0) from:C:\Program Files (x86)\AutoIt3 input:C:\Programs\AutoIt-Bugs\TestAdmin.au3 +>10:52:13 AU3Check ended.rc:0 >Running:(3.3.16.0):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\Programs\AutoIt-Bugs\TestAdmin.au3" +>Setting Hotkeys...--> Press Ctrl+Alt+Break to Restart or Ctrl+BREAK to Stop. +>10:52:14 AutoIt3.exe ended.rc:0 +>10:52:15 AutoIt3Wrapper Finished. >Exit code: 0 Time: 2.236
End-of-line comment after the directive #RequireAdmin suppresses consolewrite() and consoleerror() output.
The script runs with admin-rights and the script functions normal except for the output of consolewrite() and consoleError()
It seems that (almost) everything after the #RequireAdmin causes this behavior.
With just trailing spaces the consolewrite output is visible.
other examples that fail:
#RequireAdmin #cs
#RequireAdmin #cs #ce
#RequireAdmin_
#RequireAdmin _
Additional remark: The #cs/#ce examples also confuse the syntax highlighter.
Attachments (0)
Change History (7)
comment:1 Changed 3 years ago by mLipok
- Component changed from AutoIt to SciTE4AutoIt
- Owner set to Jos
- Status changed from new to assigned
- Version changed from 3.3.16.0 to Other
comment:2 Changed 3 years ago by mLipok
comment:3 Changed 3 years ago by mLipok
Take a look on AutoIt3Wrapper.au3:
There is:
; Show Consolemessage about running a script that required elevated rights not displaying anuy console messages If $Option = "Run" And $I_Rec = "#RequireAdmin" And Not IsAdmin() Then $Shell_RQA_Diff = 1 EndIf
Check if this following change, fix this issue:
; Show Consolemessage about running a script that required elevated rights not displaying anuy console messages If $Option = "Run" And StringLeft($I_Rec, StringLen("#RequireAdmin")) = "#RequireAdmin" And Not IsAdmin() Then $Shell_RQA_Diff = 1 EndIf
btw.
Jos is the maintainer of AutoIt3Wrapper.au3 so he will decide how it will be fixed at the end.
comment:4 Changed 3 years ago by Jos
- Resolution set to Fixed
- Status changed from assigned to closed
It is now solved in the current Beta. ;)
comment:5 follow-up: ↓ 6 Changed 3 years ago by anonymous
Thanks for the quick respons and solution.
The change suggested by mLipok solves the ConsoleWrite problem.
What remains is the minor problem of confused syntax highlighting.
'#RequireAdmin #cs' makes the whole script seem to be comment.
'#RequireAdmin #cs #ce' seems to reverse code to comment and comment to code.
The script runs without problems so this is just visual weirdness but easy to solve when it happens.
comment:6 in reply to: ↑ 5 Changed 3 years ago by Jos
Replying to anonymous:
Thanks for the quick respons and solution.
The change suggested by mLipok solves the ConsoleWrite problem.
Something similar is implemented in the current Beta, but preferred to use StringRegEx(). ;)
Replying to anonymous:
What remains is the minor problem of confused syntax highlighting.
'#RequireAdmin #cs' makes the whole script seem to be comment.
'#RequireAdmin #cs #ce' seems to reverse code to comment and comment to code.
The script runs without problems so this is just visual weirdness but easy to solve when it happens.
I will have a look at that one too, but it's a totally separate "bug" in the SciLexer source for au3. ;)
As for the variations of #RequireAdmin you listed: AutoIt3 just looks for the starting characters "#RequireAdmin" after removing the whitespace and doesn't consider any extra characters after it. That is the way Directives are implemented... One Directive per line at the start.
This also means that the SciLexer really should ignore #cs after any previous directive on that line.
Groet, Jos
comment:7 Changed 3 years ago by Jos
See here for the changes to the SciTE Lexer issues you reported:
https://www.autoitscript.com/forum/topic/205465-uploaded-a-new-version-of-the-scite4autoit3exe-v2131616391/?do=findComment&comment=1498308
Guidelines for posting comments:
- You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
- In-depth discussions should take place on the forum.
For more information see the full version of the ticket guidelines here.
Strange.
If you take look on:
https://www.autoitscript.com/autoit3/scite/download/beta_SciTE4AutoIt3/History.html
It was added as a new feature at: 2-1-2019
So this should work.
I'm investigating as it still works on my other scripts.