当前我正在加载一个Powershell文件,该文件将返回一个值。有没有办法加载得更快?因为我的程序正在打开8.ps1文件,需要10到15秒才能使用。我可以启动程序,然后在程序已经运行时将字符串放入其中吗(因为它是一个Tkinter GUI)
p = subprocess.check_output(["powershell.exe", "C:\\PowershellFiles\\bios_settings.ps1"])
bios = str(p)
if bios == 'b\'[BIOS:config:Network:MACAdressPassThr]disabled\\n\\r\\n\'':
bios = '[BIOS:config:Network:MACAdressPassThr]\tdisabled'
else:
bios = '[BIOS:config:Network:MACAdressPassThr]\tenabled'
假设将字符串放入标签中,则可以在创建标签后使用.configure()方法更改标签。因此,您可以创建tkinter GUI并在powershell完成后使用.configure()对其进行更新。如果您使用了任何按钮,可以等待稍后显示或禁用它们,直到powershell命令完成
或者可以使用stringVar来更新它
但是,您未处理的字符串会在那里闪烁一瞬间
如果速度更快,您可以尝试:
另外,我相信您的脚本正在按顺序执行powershell中的脚本。我不知道脚本之间是否存在数据依赖性,但如果没有,可以考虑使用线程并发运行所有脚本:
相关问题 更多 >
编程相关推荐