系统相关
首页 > 系统相关> > psshell change task argu

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)

  

标签:PIPE,Task,ScheduledTask,STDOUT,argu,Popen,psshell,task,exe
来源: https://www.cnblogs.com/pythonClub/p/16180949.html