[英]Does a C# console app run under current user account?
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. 在我打开我的大嘴并说这是一个控制台应用程序在c#中工作的默认方式之前,我想得到一些人的意见。
Essentially, we have ac# console app the create a folder full of files from byte streams. 基本上,我们有一个ac #console app,从字节流创建一个文件夹。 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. 我认为 ,只要他们在登录时像privelaged用户一样踢它,它就会复制到共享驱动器。
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.
叹气 b / c本来太容易测试爆破的东西。
To answer the question in the title of your question, yes, a C# console app runs under whatever account you run it as. 要回答问题标题中的问题,是的,C#控制台应用程序在您运行它的任何帐户下运行。
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. 我希望我不会错过你的问题。
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. 当然,如果将其作为计划任务运行,则使用
Process
类或runas
命令,可以指定其他用户。
如果您打开任务管理器,您将在“用户名”列中看到进程所有者。
在未指定特定用户的情况下运行的任何应用程序(运行方式...)都在默认登录用户的上下文中运行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.