Sikuli과 스크립트를 사용하여 특정 프로그램의 설치를 자동화하려고합니다. 프로그램 설치 프로그램을 시작한 다음 나머지 프로그램을 실행해야했습니다. 설치의. 원하는대로Python subprocess.call 스레드가 멈 춥니 다. subprocess.popen no hang
이import subprocess
from threading import Thread
class Installer(Thread):
def __init__(self):
Thread.__init__(self)
def run(self):
subprocess.Popen(["msiexec", "/i", "c:\path\to\installer.msi"], shell=True)
i = Installer()
i.run()
print "Will show up while installer is running."
print "Other things happen"
i.join()
이 코드는 작동하지 않습니다 :이 사용하는 파이썬 2.7의 주요 과정을, 스레드를 생성하는 서브 프로세스를 호출 한 후 계속하여 예상대로이 코드는 작동
했다. 설치 프로그램을 시작한 다음 중지합니다 :
import subprocess
from threading import Thread
class Installer(Thread):
def __init__(self):
Thread.__init__(self)
def run(self):
subprocess.call("msiexec /i c:\path\to\installer.msi")
i = Installer()
i.run()
print "Will not show up while installer is running."
print "Other things happen"
i.join()
나는 프로세스가 종료 될 때까지 기다리는 것을 이해합니다. 왜 그것은 메인 스레드가 계속되지 못하게합니까? 프로세스 호출 직후에 메인이 즉시 실행을 계속해야합니까?
왜 행동에 차이가 있습니까?
방금 최근에 스레드 C를 사용하기 시작했습니다.
아마도 관리자 권한이 문제 일 수 있습니다. Subprocess.call ([ 'runas', '/ user : Administrator', 'c : \ path \ to \ installer.msi']을 시도하십시오) –
설치 명령에 명령 줄 매개 변수를 추가하여 자동 설치되도록하십시오 설치 하시겠습니까? –