Is it possible to configure this command to not display the yes/no (UAC do you want to allow this application to make changes to your device?) to run as administrator? to go straight or make it not appear?

Adren Tech 0 Reputation points
2023-05-05T14:51:47.65+00:00
Is it possible to configure this command to not display the yes/no (UAC do you want to allow this application to make changes to your device?) to run as administrator? to go straight or make it not appear?

comand:

import pyuac
from pathlib import Path
import shutil

def main():
    print("Do stuff here that requires being run as an admin.")
    dir_path = Path('C:/Users/RIEIDI~2/AppData/Local/Temp')
    for file_path in dir_path.iterdir():
        try:
            if file_path.is_dir():
                shutil.rmtree(file_path)
            else:
                file_path.unlink()
        except OSError:
            print(f"Error deleting {file_path}")
    input("Press enter to close the window. >")

if __name__ == "__main__":
    if not pyuac.isUserAdmin():
        print("Re-launching as admin!")
        pyuac.runAsAdmin()
    else:
        main() 
Windows for business | Windows Client for IT Pros | User experience | Other
Community Center | Not monitored
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Limitless Technology 44,766 Reputation points
    2023-05-09T12:16:57.9033333+00:00

    Hello,

    Here's the steps you can try.

    -Click start, type Change User Account Control Settings

    -Set it to Never Notify and click Ok save the changes.

    Restart your pc and try to open the app.

    I hope the information above helps.

    or

    Press the Windows key, type task, and select the Task Scheduler option.

    Click the Task Scheduler Library folder on the left and select New Folder.

    Now, give the new folder a title and click on it.

    Click on Create Task.

    Next, enter the title of the program you need to open with elevated privileges in the Name box.

    Select the Run with highest privileges option on the General tab.

    Now, select your PC’s platform from the Configure for dropdown menu.

    Click the Actions tab and select New.

    From here, select Start a program from the Action dropdown menu and click the Browse button to select the program for the task to open.

    Next, click the OK button on the New Action and Create Task windows, respectively.

    Now, you should see the task listed in the new folder you set up. Select the task and press the Run button on the right of the window to check that it works.

    Press the End button to close the program.

    From here, right-click your desktop and select New > Shortcut

    Enter schtasks /run /TN “folder\filename” in the text box. Replace the folder with the Task Scheduler Library subfolder title you set up, and replace the filename with the actual task title (as entered in the General tab).

    Press the Next button to input a shortcut title.

    Finally, click the Finish button to add the new shortcut to your desktop.

    While switching off the UAC is a quick way to eliminate the do you want to allow this app to make changes to your device

    And see if it helps,

    Thank you

    --If the reply is helpful, please Upvote and Accept as answer--

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.