C# 控制台应用程序是否在当前用户帐户下运行?

发布于 2024-10-16 16:41:04 字数 246 浏览 1 评论 0原文

在我张开大嘴说这是控制台应用程序在 C# 中工作的默认方式之前,我想听听你们中的一些人的意见。

本质上,我们有 c# 控制台应用程序来创建一个充满字节流文件的文件夹。很简单。他们现在希望将其直接写入只有少数人具有读/写权限的共享驱动器。

我认为只要他们以特权用户身份登录时启动 exe,它就会复制到共享驱动器。

不幸的是,他们想要这些信息而不先创建文件夹并共享。 叹息 b/c 仅仅测试这个该死的东西就太容易了。

Before I open my big mouth and say it is the default way a console app works in c# I wanted to get a few of you folks opinion.

Essentially, we have a c# console app the create a folder full of files from byte streams. Pretty simple. They now want to have it write directly to a shared drive that only a few people have read/write privilages.

I think that as long as they kick of the exe while logged in as as privelaged user it will copy to the share drive.

Unfortunately, they want this information without creating the folder and share first. sigh b/c that would have been too easy to just test the blasted thing.

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

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

发布评论

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

评论(4

神魇的王 2024-10-23 16:41:04

要回答问题标题中的问题,是的,C# 控制台应用程序在您运行它的任何帐户下运行。

请注意,您应该能够右键单击可执行文件,然后单击“以身份运行”或“以管理员身份运行”,而不是实际以其他用户身份登录。

我希望我没有错过你问题的要点。

To answer the question in the title of your question, yes, a C# console app runs under whatever account you run it as.

Note, you should be able to right click on the executable and click "run as" or "run as administrator" instead of actually logging on as another user.

I hope I'm not missing the point of your question.

国粹 2024-10-23 16:41:04

默认情况下,是的,它将在登录的用户凭据下运行(与任何其他应用程序一样)。

当然,如果这是作为计划任务运行,使用 Process 类或 runas 命令,则可以指定不同的用户。

By default, yes, it will run under the logged in user credentials (as would any other application).

Of course, if this is run as a scheduled task, uses the Process class or the runas command, one can specify a different user.

等风也等你 2024-10-23 16:41:04

如果您打开任务管理器,您将在“用户名”栏中看到进程所有者。

If you open task manager, you will see the process owner in the "User Name" collumn.

江湖彼岸 2024-10-23 16:41:04

任何未指定特定用户(运行为...)运行的应用程序都在默认登录的用户上下文中运行。

Any application run without specifying a specific user (Run as...) runs under default logged in user's context.

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