首页 > 解决方案 > 在批处理文件中以另一个 Windows 用户身份运行单个命令

问题描述

我有以下批处理文件(在 Jenkins 中)。我只想以另一个 Windows 用户身份运行“SqlPackage.exe”命令。我有它的域用户 ID 和密码。

批处理文件:

CD Folder_Name
DEL Another_Folder
SqlPackage.exe /Action:Script /sf:DB.dacpac /Profile:publish.xml /TargetServerName:Server1   /op:Publish.sql
Copy Publish.sql Somewhere_Folder

我知道我可以使用 Windowsrunas功能以其他用户身份运行批处理文件。但是,在这种情况下,我只想运行单个命令(sqlpackage.exe)。

可能吗?

标签: powershellbatch-filecmd

解决方案


推荐阅读