如何使 Windows 软件在脚本中以不同用户身份运行?

发布于 2024-07-06 04:22:17 字数 156 浏览 6 评论 0原文

我正在使用一个构建脚本来调用 Wise 来创建一些安装文件。 问题是 Wise 许可证只允许它在一个特定的用户帐户下运行,该帐户与我的构建脚本运行的帐户不同。 我知道 Windows 有 runas 命令,但这对于自动脚本不起作用,因为无法通过命令行输入密码。

I'm using a build script that calls Wise to create some install files. The problem is that the Wise license only allows it to be run under one particular user account, which is not the same account that my build script will run under. I know Windows has the runas command but this won't work for an automated script as there is no way to enter the password via the command line.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

茶底世界 2024-07-13 04:22:17

这可能会有所帮助,这是我在另一个项目中使用的一个类,可以让人们创建自己的帐户; 每个人都必须有权访问该程序,但不能允许同一帐户访问 LDAP 内容,因此该程序使用此类以不同的用户身份运行它。

http://www.codeproject.com/KB/dotnet/UserImpersonationInNET.aspx

This might help, it's a class I've used in another project to let people make their own accounts; everyone had to have access to the program, but the same account couldn't be allowed to have access to the LDAP stuff, so the program uses this class to run it as a different user.

http://www.codeproject.com/KB/dotnet/UserImpersonationInNET.aspx

你怎么敢 2024-07-13 04:22:17

我建议查看 CPAU

用于启动进程的命令行工具
在备用安全上下文中。
基本上这是 runas 的替代品。
还允许您创建作业文件
并对 id、密码和
文件中的命令行,因此可以
普通用户使用。

您可以像这样使用它(示例):

CPAU -u user [-p password] -ex "WhatToRun" [switches]

或者您可以创建一个“.job”文件,其中包含编码的用户和密码。 这样您就可以避免将用户的密码放入构建脚本中。

I recommend taking a look at CPAU.

Command line tool for starting process
in alternate security context.
Basically this is a runas replacement.
Also allows you to create job files
and encode the id, password, and
command line in a file so it can be
used by normal users.

You can use it like this (examples):

CPAU -u user [-p password] -ex "WhatToRun" [switches]

Or you can create a ".job" file which will have the user and password encoded inside of it. This way you can avoid having to put the password for the user inside your build script.

小…楫夜泊 2024-07-13 04:22:17

这是一种临时解决方案,但您可以创建一个以您的用户帐户运行的计划任务,并让它定期运行(也许每分钟一次)。 是的,您必须等待它运行。

然后,该任务可以查找一些要处理的数据文件,并且仅当它们存在时才执行实际工作。

It's a bit of a workaround solution, but you can create a scheduled task that runs as your user account, and have it run regularly, maybe once every minute. Yes, you'll have to wait for it to run then.

This task can then look for some data files to process, and do the real work only if they are there.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文