服务或由具有管理权限的服务启动的程序
为了更新我们的软件,我们使用了 VB6 更新程序,具有更新级别和不同的更新源。它将必要的文件从更新源复制到本地目标 (C:\program files\company\product)。
VB6 程序只能使用服务助手(srvany 或类似的)作为服务运行,并且没有足够的权限在给定文件夹中更改或添加新文件。但即使是 .NET 程序也没有必要的权限来执行此操作,除非您在服务上设置管理员凭据。
如果客户端不会使用管理员凭据设置服务,我们如何使用服务或服务调用的程序来更改给定文件夹中的文件,这意味着它具有管理权限。
由于给定的更新级别(不同的用户具有不同的程序和报告版本),MSI/MSP 是不可能的。
我们尝试从 C#.NET 服务调用外部程序并进行提升,但没办法... 我们检查了清单文件的一些提示和技巧,或者考虑创建一个可以拥有管理权限的 COM 对象,但我认为这是错误的方法。
另一种可能性是通过给予“最高特权”来创建计划任务。但这有效吗?如果任务应该在登录后运行并且不同的用户可以使用这台计算机,那么您应该为每个用户定义一个任务...我们不知道客户端计算机上的每个登录,因为它们经常更改。
有人可以帮忙吗?
For updating our software we used a VB6 updating program, with update levels and different update sources. It copied the necessary files from the update sources to the local destination ( C:\program files\company\product).
VB6 programs can only run with a service helper (srvany or similar) as a service and don't have enough rights to change or add new files in the given folder. But even a .NET program has not the necessary rights to do it, only if you set the administrator credentials on the service.
If the client would not set the service with the administrator credentials, how can we use a service or a program called by a service to changes the files in the given folder, means that it has administrative rights.
MSI/MSP is not possible because of the given update levels (different users with different program and report versions).
We tried to call an external program from a C#.NET Service with elevation, but no way...
We checked out some tipps and tricks with manifest files or thought to make a COM object that could have administrative rights, but I think this is the wrong way.
Another possibility is to create a scheduled task by giving the 'hightest pivilege'. But does that work? If the task should run after login and different users could use this computer, you should define a task for each user... We don't know each login on the clients computer, because they change very often.
Can somebody help please?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要启动提升的功能,您需要一个作为本地系统运行的服务,以便它具有访问程序文件所需的权限。然而服务始终运行并占用内存。
您可以创建一个计划任务,该任务将在一段时间后启动。不过,我不确定是否可以在没有 UAC 确认的情况下运行提升的任务。
清单还应该允许您启动另一个提升的应用程序。
基本上,您的更新程序不需要提升:它可以将更新文件下载到每个用户都可写的
ProgramData
中。下载完成后,它会启动需要管理权限的安装程序。Firefox 使用自动更新机制:当下载较新版本时,它会提示提升以应用更新。
Apple Quicktime 使用计划任务来启动更新程序。它提供了一个界面,用户可以在其中选择他们想要安装的更新。它会下载更新文件,提示提升权限,然后应用更新。
如果您不希望任何用户交互,那么服务是最好的选择。
To start something elevated, you need a service that runs as local system so that it has the required privileges to access Program Files. Yet service always runs, and takes memory.
You can create a scheduled task which will start after a certain period of time. I'm not sure, though, it's possible to run a task elevated without UAC confirmation.
Manifests should also allow you to start another application elevated.
Basically your updater does not need to be elevated: it can download the update files into
ProgramData
which is writable by each user. When download completes, it starts the installer requiring the administrative privileges.Firefox uses auto-update mechanism: when it downloaded a newer version, it prompts for elevation to apply the update.
Apple Quicktime uses a scheduled task to start the updater. It presents interface where users can select what updates they want to install. It downloads the update files, prompts for elevation and then applies the updates.
If you do not want any user interaction, then service is the best bet.