以管理员身份使用 AzureDevOps 命令行 [英] AzureDevOps commandline as administrator

查看:19
本文介绍了以管理员身份使用 AzureDevOps 命令行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 azure devops 发布管道中使用 cmd 任务停止 Topshelf 服务.我所做的是创建以下脚本的 CommandLineTask:

I would like to stop Topshelf service using cmd task in azure devops release pipeline. What I do is create CommandLineTask which following script:

ServiceName.exe 停止

ServiceName.exe stop

作为输出,我看到

v3.1.4 2020-06-05T10:14:20.1312163Z ServiceName 服务只能被管理员阻止

v3.1.4 2020-06-05T10:14:20.1312163Z The ServiceName service can only be stopped by an administrator

我的问题是是否有办法以管理员身份运行此 CommandLineTask?

My question is if there is a way to run this CommandLineTask as an administrator?

附注.我在服务本身存在的虚拟机上使用代理

PS. I use agent on my virtual machine where the service exist itself

推荐答案

由于您使用的是自托管代理,您可以尝试使用管理员帐户(本地系统管理员)创建和运行代理.

Since you are using the self-hosted agent, you could try to use the administrator account (Local system admin) to create and run the agent.

对于交互模式自托管代理:

For interactive mode self-hosted agent:

您可以使用以下命令创建具有管理员帐户的代理.

You could use the following command to create an agent with admin account.

.\config.cmd --unattended --url https://myaccount.visualstudio.com --auth pat --token myToken --pool default --agent myAgent --runAsAutoLogon --windowsLogonAccount myDomain\adminaccount --windowsLogonPassword Password

对于服务模式自托管代理:

For service mode self-hosted agent:

一方面,您可以使用管理员帐户创建代理(类似于交互模式).

On one hand, you could create an agent with the admin account(similar as interactive mode).

.\config.cmd --unattended --url https://myaccount.visualstudio.com --auth pat --token myToken --pool default --agent myAgent --runAsService --windowsLogonAccount myDomain\adminccount --windowsLogonPassword Password

另一方面,您可以导航到本地系统 -> 服务并找到正在运行的代理服务.

On the other hand, you could navigate to local system -> Service and find the running agent service.

然后您可以将 logon account 更改为管理员帐户.

Then you could change the logon account as admin account.

这是关于 创建代理.

这篇关于以管理员身份使用 AzureDevOps 命令行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆