我对Python编程有问题。在我的程序中,我使用os.startfile()来启动程序,但它不允许我这样做。
当我的程序执行启动文件的命令时,我在Windows脚本主机中收到以下错误:Script: C:\Users\Personal Name\Desktop\Program\Files\Volume\Volume Max\Volume Max.vbs
Line: 3
Token: 1
Error: Can't find the file.
Code: 80070002
Source (null)
我把文件放在路径正确的地方,名字拼写正确。我已经复查过了。我删除了文件名中的空格,并查找了未成功获得的错误代码,因为Windows对其他Windows文件有相同的错误。
现在我可能错了,这不是Python错误,但我想是的。
代码:import socket
import time
import os
host = '192.168.56.1'
port = 5000
clients = []
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.bind((host, port))
s.setblocking(0)
quitting = False
print ("Server Started")
while not quitting:
try:
data, addr = s.recvfrom(1024)
if ("Quit") in str(data):
quitting = True
print (time.ctime(time.time()) + str(addr) + str(data))
if "Volume Max" in data:
print ("Volume Max")
os.startfile('C:\\Users\\wbe0719\\Desktop\\Program\\Files\\Volume\\Volume Max\\Volume Max.vbs')
except:
pass
s.close()