【问题标题】:How to end the running of python script that started SSMS? [duplicate]如何结束启动 SSMS 的 python 脚本的运行? [复制]
【发布时间】:2021-09-21 08:00:19
【问题描述】:

我有以下代码从python 脚本运行 SSMS(因为我希望它在我开始工作之前自动运行):

import os
run_line = ' '.join(['ssms.exe', '-S', server_name, '-U', user_name, '-P', my_password])
os.system('cmd /c ' + run_line)

其中server_name user_name my_password 保存ssms.exe 运行的参数。 它工作并使用用户名和密码启动 SSMS,但脚本在我关闭 SSMS 或手动关闭之前不会终止。 如何在不关闭 SSMS 的情况下自动运行程序并结束脚本?

【问题讨论】:

标签: python cmd ssms os.system


【解决方案1】:

我不知道这是否对你有帮助,但我经常使用

import sys
sys.exit()

sys.exit() 将停止你的程序运行

【讨论】:

  • 它没有帮助,因为脚本停留在os.system 行中,并且在它之后不会运行任何东西。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-11-18
  • 1970-01-01
  • 1970-01-01
  • 2023-02-24
  • 1970-01-01
相关资源
最近更新 更多