Sign in to follow this  
Followers 0
LVCVA

Running Windows Defrag as a Standard User in Vista

4 posts in this topic

Hello,

I don't know if this is possible but I would like to be able to give our users who are not local Admins the ability to run Windows Defrag. We are running Windows Vista and per company policy this includes having UAC turned on. Here is what I am trying:

CODE
; Run Windows Defrag as an Administrator

; Needed to run this script on Windows Vista with UAC on

#RequireAdmin

; Run as local Administrator

If Not isAdmin() then

$pwd = "password"

RunAsSet("administrator",@ComputerName,$pwd)

endIf

RunWait("c:\windows\system32\dfrgui.exe")

But when this runs as a standard user, they are still prompted for admin credentials. Is there a way to get around this?

Share this post


Link to post
Share on other sites



You can't run in the context of another user and display the GUI to a different user in Vista (as far as I know). PSEXEC lets you do this on XP, but I don't think there's a way to do this on Vista yet (or ever, considering you're running UAC).

Share this post


Link to post
Share on other sites

You can't run in the context of another user and display the GUI to a different user in Vista (as far as I know). PSEXEC lets you do this on XP, but I don't think there's a way to do this on Vista yet (or ever, considering you're running UAC).

I suspected as much, but thank you for your reply.

Share this post


Link to post
Share on other sites

But when this runs as a standard user, they are still prompted for admin credentials. Is there a way to get around this?

Either you choose to use #RequireAdmin or use RunAsSet(), but not both within the same instance of execution. Others have reported that using both fails. If you want to have a prompt, then use #RequireAdmin. If you want no prompt, then use RunAsSet(). AFAIK, IsAdmin() may not work as expected with UAC on and further testing may prove that.

:)

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