简体   繁体   English

Windows完全启动后如何确保C#应用程序启动

[英]How to ensure C# application starts after windows is booted compltely

I want to create a simple checker console application that should run at startup on developer's machines and check some items. 我想创建一个简单的检查器控制台应用程序,该应用程序应在启动时在开发人员的计算机上运行并检查某些项目。 This is to make sure that all developers are working according to a predefined policy that gets updated on regular basis. 这是为了确保所有开发人员都根据预先定义的策略进行工作,该策略会定期更新。

Everything works just fine, except that this console application runs before Windows is truly booted (user is not logged in yet), and our application encounters access denied exceptions in some places. 一切运行正常,除了此控制台应用程序在真正启动Windows(用户尚未登录)之前运行之前,并且我们的应用程序在某些地方遇到拒绝访问的异常。

In this answer , it's suggested that we either change the console to Windows service, or make it a Windows scheduled task, none of which is desirable in our situation. 此答案中 ,建议我们将控制台更改为Windows服务,或者将其设置为Windows计划的任务,在我们的情况下,这些都不是理想的。

Is there any way to check that Windows is fully booted, and user is logged in (for example in a while loop) and after that continue the code in .NET? 有什么方法可以检查Windows是否已完全启动,并且用户已登录(例如,在while循环中),然后在.NET中继续执行代码?

  1. If you can configure windows service with user's credentials (you know user's password or can ask user to configure service), u can install windows service with users's credentials. 如果您可以使用用户的凭据(您知道用户的密码或可以要求用户配置服务)来配置Windows服务,则您可以使用用户的凭据来安装Windows服务。 Select Automatic Delayed Start (explain here ). 选择自动延迟启动( 在此处说明)。 This service will start even if user is not logon yet, but with his credentials. 即使用户尚未登录但使用其凭据也将启动此服务。
  2. You can use Startup folder 您可以使用启动文件夹
  3. You can use registry run\\regedit 您可以使用注册表运行\\ regedit

open 打开

[HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run] [HKEY_CURRENT_USER \\ Software \\ Microsoft \\ Windows \\ CurrentVersion \\ Run]

For each program you want to start automatically create a new string value using a descriptive name, and set the value of the string to the program executable 对于要启动的每个程序,将使用描述性名称自动创建一个新的字符串值,并将该字符串的值设置为程序可执行文件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 c# 如何检测windows 表单应用程序在计算机启动后首次运行(启动时)? - c# how to detect that the windows form application runs for the first time(on startup) after computer starts? C#:以编程方式检测 Windows Server 已启动 - C#: Programmatically Detect Windows Server Has Booted 在Windows 8中启动任何应用程序时,如何启动我的C#应用​​程序? - How to launch my C# application when any application starts in Windows 8? 当Windows启动时,如何使我们的表单(应用程序)开始运行? - How to make our form(application) start running when windows starts in C#? Windows注销后如何继续运行C#应用程序 - how to keep running C# application after windows log off 如何编写C#Regex以确保字符串以一个char后跟6位开头 - How to write a C# Regex to ensure a string starts with one char followed by 6 digits 如何确保Winform应用程序仅一个实例C# - How to ensure only one instance of an winform application C# c# - 如何确保在崩溃时保存应用程序状态 - How to ensure saving of application state on crash c# 安装后C#Windows应用程序崩溃 - c# windows application crashes after installation 如何在C#应用程序启动时正确运行代码? - How to run code right when a C# application starts?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM