Rogue5099 Posted April 7, 2014 Share Posted April 7, 2014 With the following code I want to read the system defrag status to a GUI. I have UAC disabled on my PC and I am able to get the results. When I run this on other PC's it says they don't have the correct privileges. $iPID = Run(@ComSpec & ' /C defrag ' & @HomeDrive & ' /a /v', "", @SW_HIDE, $STDOUT_CHILD) I have #RequireAdmin at the begining of my script but this still does not pass on to a sub-process. I don't mind UAC interrupting and asking for permission. Even tried RunAs() but each computer's Password is different if even non existent. I see how to open cmd by clicking start menu, typing cmd, right clicking Command Prompt, clicking Run As Admin does work but how do I tell CMD that through AutoIt? (This is not for a network just several local computers.) I just want to run the above line in Admin CMD and have UAC prompt if needed. My projects: Inventory / Mp3 Inventory, Computer Stats Link to comment Share on other sites More sharing options...
Rogue5099 Posted April 10, 2014 Author Share Posted April 10, 2014 (edited) I'm still at a loss here. I've tried several ways to get this to no avail. Edited April 10, 2014 by Rogue5099 My projects: Inventory / Mp3 Inventory, Computer Stats Link to comment Share on other sites More sharing options...
Gianni Posted April 10, 2014 Share Posted April 10, 2014 I do not know if >this will be useful... Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
jguinch Posted April 10, 2014 Share Posted April 10, 2014 Sub-processes started by a program that has itself been run with elevated privileges normally inherit the elevation.The problem may be that the user is not a member of the administrators group (which is required to run defrag). You can add a check for this in your code : #RequireAdmin If NOT IsAdmin() Then Exit MsgBox(16, "Error", "Access denied") Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now