如何为单击一次应用程序指定用户凭据?

发布于 2024-09-16 09:51:57 字数 102 浏览 7 评论 0原文

对于常规 .exe 文件,我始终可以右键单击并选择“运行为..”。如何以类似的方式在不同的凭据下运行 Click-Once 应用程序?

我说的是应用程序本身,而不是安装程序。

For a regular .exe file i can always right click and select "run as..". How can i run a Click-Once application under different credentials in a similar way?

I am talking about the application itself, not the installer.

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

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

发布评论

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

评论(3

我ぃ本無心為│何有愛 2024-09-23 09:51:57

其实这是可以的,只需要两步就可以了。首先,您需要以您尝试模拟的用户身份启动 ClickOnce (dfsvc.exe),然后您可以使用 rundll32 启动部署应用程序,如下所示:

(从命令行)

1.- 单击一次:

runas /user:domain\user "c:\Windows\Microsoft.NET\Framework\v4.0.30319\dfsvc.exe"

2.- 启动应用程序:

runas /user:domain\user "rundll32 c:\Windows\System32\dfshim.dll,ShOpenVerbApplication http://someurl.com/tool.application"

请注意,如果您需要启动多个应用程序,则只需运行 dfsvc.exe 一次,一旦您关闭所有模拟的应用程序,它会在一段时间后消失单击一次应用程序。

This is actually possible, you just need to do it in two steps. First you'll need to launch ClickOnce (dfsvc.exe) as the user you are trying to impersonate and then you can launch the deploy application using rundll32, something like this:

(From the command line)

1.- Click once:

runas /user:domain\user "c:\Windows\Microsoft.NET\Framework\v4.0.30319\dfsvc.exe"

2.- Launch app:

runas /user:domain\user "rundll32 c:\Windows\System32\dfshim.dll,ShOpenVerbApplication http://someurl.com/tool.application"

Note that you only need to run dfsvc.exe once if you need to launch multiple apps and it will go away after a while once you close all your impersonated click once applications.

眸中客 2024-09-23 09:51:57

答案确实是否定的,你不应该这样做。 ClickOnce 应用程序安装在用户配置文件下,并且仅属于该用户。它们不会也不会作为全用户安装运行。

另请注意,如果您双击 [exe] 文件(每次更新时其位置都会更改),它不会查找更新,也不会检查文件以确保它们没有被篡改和。换句话说,它不会作为 ClickOnce 应用程序运行。

我还认为在查询字符串中传递用户名和密码是不明智的,因为任何运行 fiddler 或 charles 或任何其他网络流量嗅探器的人都能够看到凭据。

The answer really is no, you shouldn't do this. ClickOnce applications are installed under the user profile and belong only to that user. THey will not and do not work as an all-user installation.

Also note that if you double-click on the [exe] file (the location of which changes every time there is an update), it will not look for updates, it will not check the files to make sure they haven't been tampered with. In other words, it will not run as a ClickOnce application.

I also think passing the username and password in the query string is ill-advised because anybody running fiddler or charles or any other network traffic sniffer will be able to see the credentials.

羁〃客ぐ 2024-09-23 09:51:57

您是在谈论一次性过程,还是每次代码在多台计算机上运行时都需要发生的事情?因为如果您只是想以提升的权限亲自运行 ClickOnce 应用程序,这非常简单。应用程序驻留在 %LOCALAPPDATA%\Apps\2.0[ObfuscatedFolderName] 后单击。只需找到您的应用程序文件夹(时间戳应该是足够的信息),然后右键单击您的 EXE 并以管理员身份运行。

如果您想在代码中执行此操作,最简单的解决方案可能是围绕您的代码创建一个 shell 启动器应用程序,该应用程序请求代码中的提升权限。 这是一个这样的示例。

Are you talking about a one off process, or something that needs to happen every time your code is run on multiple computers? Because if you simply want to personally run a ClickOnce app with elevated permissions, its pretty simple. Click once apps reside at %LOCALAPPDATA%\Apps\2.0[ObfuscatedFolderName]. Simply find your app folder ( timestamp should be enough information ), then rightclick your EXE and run as admin.

If you want to do it in code, the easiest solution is probably to make a shell launcer application around your code, that requests elevated permissions in code. Here is such an example.

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