Sign in to follow this  
Followers 0
Razorblade1979

Admin Rights

11 posts in this topic

I am new to this forum

Fist I tried making some simple batch scripts but I had a big problem: copying files to for example C:Program files because of admin rights(runned as administartor etc output was acces denied

When I write something simular in autoIT will this solve my problem

Hope some of you guys can help me out searched everywhere :

Greetings Razorblade

 

Share this post


Link to post
Share on other sites



Razorblade1979,

Welcome to the AutoIt forum. :)

Look at #RequireAdmin in the Help file - that will run the script with Admin rights and should solve your problem, although you will still have to enter the Admin credentials as the script starts. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

   Hmmm.... my #requireadmin seems to have worked quite well until today. I tried it on a friends W7 64-bit and when not an administrator the mouse cursor just spun and the computer got really messed up. Couldn't close Windows or anything. I then fired up my Windows 7 64-bit laptop and got the same results. I know it use to work. It use to pop up and ask for credentials but then I started thinking about it. I don't think I ever ran the script under 64-bit WIndows.

   If you look at the help file for #requireadmin it states it is for Windows 2000, XP and Vista. It does not mention Windows 7 or WIndows 8 let alone 64-bit. Is #requireadmin Windows 7 and Windows 8 compatible? 32 and 64-bit? 

   I started look for alternatives and found IsAdmin() but the help file is a little lacking on it too. Does IsAdmin() with Windows 7 and 8 both 32 abd 64 bit?

Share this post


Link to post
Share on other sites

#RequireAdmin works perfectly fine on all version of Windows. Even Windows Blue (8.1). 

Share this post


Link to post
Share on other sites

There was a trak ticket  #1498 regarding this, if the UAC is turned off on the system.


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

Share this post


Link to post
Share on other sites

   Hmm... I am almost going to have to disagree. I use the #RequireAdmin on a install program. As mentioned above I tried installing on a customer's Windows 7 64-bit computer this morning and when I ran the script all it did was circle the mouse cursor and virtually hang the computer. I then ran it on my Windows 7 64-bit. It ran fine but I am an administrator. I created a normal user, logged in as that normal user, and got the same results as on my customer's. Spinning mouse cursor and things were hung up. The strange part is I swear it use to work. That it use to pop up and ask for credentials if you weren't an administrator. Have you tried it recently? Do you know what might have changes?

Along the same line:

If IsAdmin() = 1 Then
   MsgBox(0, "", "You are an admin")
Else
   MsgBox(0, "", "You aren't an admin")
EndIf
 

Seems to work find on XP and both Windows 7 32 abd 64 but not on Windows 8.....

Share this post


Link to post
Share on other sites

Disagree with who, and in regards to what?


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

Share this post


Link to post
Share on other sites

Disagree with 0xdefea7. But... not totally disagree. It works with all versions of Windows as long as UAC is enabled. You nailed it BrewManNH. That is "what has changed". I disabled UAC and logging in as a normal user sends the script in to la la land. 

I guess in my case IsAdmin() would work better because is doesn't seem to rely on UAC and if they aren't an administrator I simply want to quit the script.

Share this post


Link to post
Share on other sites

 

I guess in my case IsAdmin() would work better because is doesn't seem to rely on UAC and if they aren't an administrator I simply want to quit the script.

That would be the best route to go, because as JohnOne said, using it doesn't give you the rights to run it, it just asks you for them.


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

Share this post


Link to post
Share on other sites

I still don't see how you can disagree with me at all. The issue was not with the function, it was with your environment. The function works as expected, on all versions of Windows.

Share this post


Link to post
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
Sign in to follow this  
Followers 0