# -*- coding: UTF-8 -*-
import os
import shutil
import subprocess
def autoDel(arg, dirname,names):
for name in names:
if os.path.isdir(os.path.join(dirname,name)) and name == 'SafeNet Sentinel':
try:
print os.path.join(dirname,name)
shutil.rmtree(os.path.join(dirname,name))
except:
print '删除失败'
os.system("pause")
def autoExec(arg, dirname,names):
for name in names:
if os.path.isfile(os.path.join(dirname,name)) and name == 'instdemo.exe':
try:
print os.path.join(dirname,name)
p = subprocess.Popen(os.path.join(dirname,name), stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.PIPE, shell = True)
print p
except:
print '执行失败'
os.system("pause")
if __name__ == '__main__':
path = "C:\\"
os.path.walk(path, autoDel,())
os.path.walk(path, autoExec,())
import os
import shutil
import subprocess
def autoDel(arg, dirname,names):
for name in names:
if os.path.isdir(os.path.join(dirname,name)) and name == 'SafeNet Sentinel':
try:
print os.path.join(dirname,name)
shutil.rmtree(os.path.join(dirname,name))
except:
print '删除失败'
os.system("pause")
def autoExec(arg, dirname,names):
for name in names:
if os.path.isfile(os.path.join(dirname,name)) and name == 'instdemo.exe':
try:
print os.path.join(dirname,name)
p = subprocess.Popen(os.path.join(dirname,name), stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.PIPE, shell = True)
print p
except:
print '执行失败'
os.system("pause")
if __name__ == '__main__':
path = "C:\\"
os.path.walk(path, autoDel,())
os.path.walk(path, autoExec,())