Jump to content

How to ConsoleWrite after #RequireAdmin?


SadBunny
 Share

Recommended Posts

#RequireAdmin

ConsoleWrite("hoi"&@CRLF)

Nothing is written to the console though the script runs fine. (Using Windows 7, 32 bits.) If I don't #RequireAdmin, I see the console output.

[edit: I think something is in fact written to *some* console, just not the one I'm seeing or something.]

I'm guessing running a script as administrator it still writes to the console but just not the console that the Scite window is handling... Because if I start Scite as administrator, then I can see the console output after a #RequireAdmin. What puzzles me though is that if I start Scite as admin and I DON'T #ReqAdm, then I can still see the output!

Run Scite as admin + ConsoleWrite = I see output

Run Scite as admin + #RequireAdmin + ConsoleWrite = I see output

Run Scite as user + ConsoleWrite = I see output

Run Scite as user + #RequireAdmin + ConsoleWrite = I see NO output!

?

Edited by SadBunny

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Link to comment
Share on other sites

From the help file

Remarks

This function was primarily aimed at allowing AutoIt scripts to work correctly with Windows Vista User Account Control (UAC) (However, will also work on Windows 2000 and Windows XP).

For more details see AutoIt on Windows Vista.

As this function launch a new process, some functions as Consolewrite() cannot be captured (Scite will not display anything).

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

From the help file

Thanks. I did read that, but as I pointed out in my previous post I can see the ConsoleWrite output just fine after a #RequireAdmin as long as I start Scythe as administrator... So I think the help file might be cutting corners on this subject somewhat.

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Link to comment
Share on other sites

Because what is doing is running the script as another user than who started the scite session.

That is of course if you do not start scite as admin, as then you are the same user.

Get it now?

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

No, sorry but actually I don't, since when I run Scite as admin and I don't include the #RequireAdmin, I still see the console output. Or is the interpreter itself ran as admin when you start scite as admin? I guess it is. Never mind! Thanks for helping.

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Link to comment
Share on other sites

When you run SciTe as an admin, and then run the script, you are running it as an Admin it doesn't need to be restarted to run as Admin with the #requireadmin directive. If you run Scite as a regular user and then start the script, it's STARTED as by the regular user, the #requireadmin directive will then RESTART the script as an admin. Because it's being started a second time, in a different user's namespace, it's not visible to SciTe any longer.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

When you run SciTe as an admin, and then run the script, you are running it as an Admin it doesn't need to be restarted to run as Admin with the #requireadmin directive. If you run Scite as a regular user and then start the script, it's STARTED as by the regular user, the #requireadmin directive will then RESTART the script as an admin. Because it's being started a second time, in a different user's namespace, it's not visible to SciTe any longer.

Ok, that clears it right up indeed! :graduated: Thanks for your effort.

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Link to comment
Share on other sites

#requireadmin is useless, if you're running a script launch AutoIt or SciTE as admin, and if you compile use #AutoIt3Wrapper_res_requestedExecutionLevel.

Link to comment
Share on other sites

  • Developers

#requireadmin is useless, if you're running a script launch AutoIt or SciTE as admin, and if you compile use #AutoIt3Wrapper_res_requestedExecutionLevel.

Its not useless when you need it ran from the au3 file like. :-)

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

#requireadmin is useless, if you're running a script launch AutoIt or SciTE as admin, and if you compile use #AutoIt3Wrapper_res_requestedExecutionLevel.

Wow, that looks a whole lot more professional! :graduated: But... Can I find that in the helpfile somewhere? Because just searching for it in the helpfile turns up nothing :(

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Link to comment
Share on other sites

Its not useless when you need it ran from the au3 file like. :-)

Yeah by the way I have used this ever since Windows Vista appeared for scripts that need to do something funky like registry writing. Always worked like a charm, both for test scripts from scythe as for compiled exes.

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Link to comment
Share on other sites

  • Developers

Wow, that looks a whole lot more professional! :graduated: But... Can I find that in the helpfile somewhere? Because just searching for it in the helpfile turns up nothing :D

That is because it is part of the SciTE4AutoIT3 installer specifically AutoIt3Wrapper functionality I created.

Look in the Helpfile that comes with that installer.

Jos :(

Edited by 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

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