Fix 'Run as Different User Access Denied' on Windows 11

Fix 'Run as Different User Access Denied' on Windows 11

If you encounter an "Access Denied" error when trying to use the "runas" command, the "Run as Administrator" option, or the "Run as a different user" option in Windows, follow these solutions to resolve the issue.

What can I do if run as a different user gives an Access denied error?​

1. Check task settings​

  1. Press the Windows key + S and type scheduler. Open Task Scheduler.
    open task scheduler search results

  2. Now locate the task that tries to run the application as a different user and double-click it.
  3. In the Security options, check Run with the highest privileges and save changes.
    run with highest privileges task settings

2. Use Group Policy​

  1. Open Group Policy Management Console:
    • Press Windows + R to open the Run dialog.
    • Type gpmc.msc and press Enter.
  2. Create a New Group Policy Object (GPO):
    • Right-click on the domain or organizational unit (OU) where you want to apply the policy.
    • Select Create a GPO in this domain, and Link it here....
    • Name the GPO and click OK.
  3. Edit the GPO:
    • Right-click on the newly created GPO and select Edit.
  4. Navigate to the Secondary Logon Service Settings:
    • Go to Computer Configuration > Policies > Windows Settings > Security Settings > System Services.
    • Find and double-click Secondary Logon.
  5. Define the Policy Setting:
    • Check the Define this policy setting box.
    • Select Enabled.
    • Set the service startup mode to Manual.
  6. Set Security Permissions:
    • Expand the Security node.
    • Ensure the following properties and objects are set to Allow:
      • Authenticated Users: Query Template, Query Status, Enumerate Dependents, Start, Pause, and continue, Interrogate, Read Permissions, User-Defined Control.
      • Builtin\Administrators: Full Control.
      • Interactive: Query Template, Query Status, Enumerate Dependents, Start, Pause, and continue, Interrogate, Read Permissions, User-Defined Control.
      • Service: Query Template, Query Status, Enumerate Dependents, Pause, and continue, Interrogate, User-Defined Control.
      • System: Query Template, Query Status, Enumerate Dependents, Start, Pause, and continue, Interrogate, Stop.
  7. Apply the Changes:
    • Click OK to apply the security changes and save the Group Policy changes.
  8. Update Group Policy:
    • Wait for Group Policy to update automatically, or force an update by running gpupdate /force in Command Prompt.
By configuring Group Policy to set the correct permissions and security settings, you ensure that the "runas" command and similar options work properly without access issues.

3. Check the services​

  1. Press Windows key + R and enter services.msc.
    services.msc run window windows 11
  2. Locate the Secondary Logon service and double-click it.
    secondary logon in services window
  3. Set the Startup Type to Automatic and click Start to start the service.
    secondary logon startup type
  4. Save changes and try to run the service again.

4. Check Task Settings​

  1. Open Task Scheduler:
    • Press Windows key + S and type scheduler.
    • Open Task Scheduler.
  2. Locate and Configure the Task:
    • Find the task that runs the application as a different user.
    • Double-click the task to open its properties.
    • In the Security options, check Run with the highest privileges.
    • Save the changes.
Configuring the task to run with the highest privileges ensures that it has the necessary permissions to execute properly.

5. Check and Modify File/Folder Permissions​

  1. Take Ownership of the Folder:
    • Right-click the folder causing the issue.
    • Select Properties.
    • Go to the Security tab.
    • Click on Advanced.
    • Next to the owner's name, click Change.
    • Type your username and click Check Names.
    • Click OK.
    • Check Replace owner on subcontainers and objects and click Apply.
  2. Grant Full Control Permissions:
    • Go back to the Security tab in the folder's properties.
    • Click Edit.
    • Select your user account from the list.
    • Check the Full Control box.
    • Click Apply and then OK.
  3. Apply Permissions to All Files and Subfolders:
    • Go back to the Security tab and click Advanced.
    • Check Replace all child object permission entries with inheritable permission entries from this object.
    • Click Apply and then OK.
By taking ownership and adjusting permissions, you ensure you have the necessary access to files and folders, eliminating "Access Denied" errors.

6. Use PowerShell​

  1. Open the command line.
  2. Use the following command, but be sure to replace [user] and [command] with the appropriate user and command:
    powershell.exe -ExecutionPolicy Bypass -command "& {Start-Process powershell.exe -Credential '[user]' -ArgumentList 'Start-Process ""[command]"" -Verb runAs'}"
    powershell run as command
By using PowerShell, you can bypass certain restrictions and run commands or applications as a different user with elevated privileges.

By following these comprehensive solutions, you can effectively resolve the "Access Denied" error when using the "runas" command, Run as Administrator, or Run as a different user option in Windows.
Author
Windows Daily
First release
Last update

More resources from Windows Daily

Top