Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

run file as administrator python

# Run file as administrator on Windows 7, 8, 10
# Tested for Python 3.8.5
import os

def RunAsAdmin(path_to_file,*args):
	os.system(r'Powershell -Command "Start-Process "'+path_to_file+'"'+ # CMD running Powershell
				' -ArgumentList @('+str(args)[1:-1]+')'+ # Arguments. [1:-1] to remove brackets
				' -Verb RunAs"' # Run file as administrator
	)

RunAsAdmin('cmd.exe','arg1','arg2')
Comment

PREVIOUS NEXT
Code Example
Python :: tkinter change button text 
Python :: python selenium get title 
Python :: plot bounds python 
Python :: pandas replace na with 0 
Python :: how to convert a pandas series from int to float in python 
Python :: converting pandas._libs.tslibs.timedeltas.Timedelta to days 
Python :: python print no end of line 
Python :: PIL Make Circle 
Python :: django create model from dictionary 
Python :: python selenium partial class name 
Python :: how to delete records in pandas before a certain date 
Python :: youtube-dl python download to specific folder 
Python :: python to golang 
Python :: semicolons in python 
Python :: timed loop python 
Python :: rightclick in pygame 
Python :: huggingface default cache dir 
Python :: python download s3 image 
Python :: jupyter notebook play audio 
Python :: cv2 videocapture program for python 
Python :: python utf8 
Python :: scaling image interpolation python 
Python :: blender python save file 
Python :: how to add row in spark dataframe 
Python :: pandas replace space with underscore in column names 
Python :: url in form action django 
Python :: format percentage python 
Python :: python isprime 
Python :: discord.py cog 
Python :: python trick big numbers visualisation 
ADD CONTENT
Topic
Content
Source link
Name
6+8 =