psshell change task argu
from subprocess import PIPE, STDOUT,Popen import traceback import subprocess # # -*- encoding=utf-8 -*- # from subprocess import Popen, PIPE, STDOUT # #进入/sdcard 下,查看文件列表 # #使用gbk格式代替utf-8,避免在解码过程中遇到中文文件名而报错 process = Popen(["powershell.exe"], shell=False, stdout=PIPE, stdin=PIPE, stderr=STDOUT) commands = ('''$Task = Get-ScheduledTask -TaskName "1t"\n''' '''$Task.Actions[0].Arguments = "x:\python.exe hhh"\n''' "Set-ScheduledTask $Task\n" ) outs, errs = process.communicate(commands.encode('gbk')) from subprocess import PIPE, STDOUT,Popen import traceback import subprocess # # -*- encoding=utf-8 -*- # from subprocess import Popen, PIPE, STDOUT # #进入/sdcard 下,查看文件列表 # #使用gbk格式代替utf-8,避免在解码过程中遇到中文文件名而报错 process = Popen(["powershell.exe"], shell=False, stdout=PIPE, stdin=PIPE, stderr=STDOUT) commands = ('''$Task = Get-ScheduledTask -TaskName "1t"\n''' '''$Task.Actions[0].Arguments = "x:\python.exe hhh"\n''' "Set-ScheduledTask $Task\n" ) outs, errs = process.communicate(commands.encode('gbk')) # # try: # output = Popen( # [r"powershell.exe", r'''$Task = Get-ScheduledTask -TaskName "1t"\n''', # r'''$Task.Actions[0].Arguments = "x:\python.exe xxxxx"\n''', # r"Set-ScheduledTask $Task\n"], # shell=True, stdout=PIPE, stderr=STDOUT) # print(output) # except BaseException: # errstr = traceback.format_exc() # print(errstr) # # try: # output = Popen( # [r"powershell.exe", r'''$Task = Get-ScheduledTask -TaskName "1t"\n''', # r'''$Task.Actions[0].Arguments = "x:\python.exe xxxxx"\n''', # r"Set-ScheduledTask $Task\n"], # shell=True, stdout=PIPE, stderr=STDOUT) # print(output) # except BaseException: # errstr = traceback.format_exc() # print(errstr)