Jump to content

Running Windows Defrag as a Standard User in Vista


 Share

Recommended Posts

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?

Link to comment
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).

Link to comment
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.

Link to comment
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.

:)

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