如何为单击一次应用程序指定用户凭据?
对于常规 .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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
其实这是可以的,只需要两步就可以了。首先,您需要以您尝试模拟的用户身份启动 ClickOnce (
dfsvc.exe
),然后您可以使用rundll32
启动部署应用程序,如下所示:(从命令行)
1.- 单击一次:
2.- 启动应用程序:
请注意,如果您需要启动多个应用程序,则只需运行 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 usingrundll32
, something like this:(From the command line)
1.- Click once:
2.- Launch app:
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.
答案确实是否定的,你不应该这样做。 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.
您是在谈论一次性过程,还是每次代码在多台计算机上运行时都需要发生的事情?因为如果您只是想以提升的权限亲自运行 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.