使用RUNAS连接到odbc?

2024-09-27 22:34:08 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试使用pyodbc连接到数据库。我可以使用ODBC数据源通过runas命令进行连接,但我似乎无法执行相同的python脚本。你知道吗

示例:

# this works
runas /netonly /user:domain\username "C:\Windows\System32\odbcad32.exe"

# this does not
runas /netonly /user:domain\username "C:\path\to\python.exe C:\path\to\script.py"

尝试执行python脚本时,窗口会快速打开和关闭。 在脚本中有一个无限打印,以确保脚本正在执行。你知道吗

#script.py
import time

while True:
   print("running")
   time.sleep(5)

Tags: topathpy脚本数据库timedomainusername

热门问题