简体   繁体   English

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

[英]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.

相关问题 无法在用户帐户下运行 C# SharpPcap 程序 - Can't Run C# SharpPcap Program Under User Account 使用C#控制台应用程序提示用户并运行SQL查询 - Using C# console app to prompt user and run SQL query 最终用户需要什么才能运行 C# 控制台程序? - What does the end user need to run a C# console program? 如何在系统 Windows 用户帐户下启动控制台应用程序? - How to start a Console App as running under the System Windows user account? 在C#应用程序中同时执行多个任务,每个任务都在一个单独的Windows用户帐户下 - Executing multiple tasks simultaneously in a C# app, each under a separate Windows user account 如何在trustedinstaller帐户下运行我的“C#”应用程序? - How to run my “C#” application under trustedinstaller account? 有没有办法在自己的帐户下运行C#程序? - Is there a way to run a C# program under it's own account? 当应用程序在不同用户下运行时,如何在 Linux 上远程调试 C#/.Net 应用程序? - How remote debug C#/.Net app on Linux when the app is run under a different user? 如何在后台运行控制台应用程序[C#] - How to run console app in background [C#] 通过在服务帐户下运行的Web服务将用户名从C#本机应用程序传递到SQL Server的好方法 - Good ways to pass user name from C# native app to SQL Server via a web service running under a service account
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM