简体   繁体   English

需要强制Windows窗体应用程序在启动时运行

[英]Need To Force Windows Forms Application To Run At Startup

I have a WinForms application that I want to auto start on login - At the moment it is just a normal standalone 'exe' 我有一个要在登录时自动启动的WinForms应用程序-目前,它只是一个普通的独立“ exe”文件

Does anyone know how to put this into the startup folder and whether that is reliable (to the extent it will get started)? 有谁知道如何将其放入启动文件夹以及它是否可靠(在一定程度上可以启动)?

If you're using the built in Setup Project in Visual-Studio then: 如果您在Visual Studio中使用内置的安装项目,则:

  1. Right click on your solution in Solution Explorer and choose View 在解决方案资源管理器中右键单击您的解决方案,然后选择查看

  2. Choose File System 选择文件系统

  3. Right click under File System on Target Machine and choose Add Special Folder 右键单击目标计算机上文件系统下的,然后选择添加特殊文件夹

  4. Choose User's Startup Folder 选择用户的启动文件夹

  5. In the empty right hand panel, right click and choose Create New Shortcut 在空白的右侧面板中,右键单击并选择创建新快捷方式

  6. Select the primary output for your Winforms exe 选择Winforms exe的主要输出

And you're done. 这样就完成了。

As Alex Reitbort says, however, it's only as robust as the target user wants it to be. 但是,正如Alex Reitbort所说的那样,它仅能满足目标用户的要求。 He's free to delete the shortcut in his Startup folder. 他可以随意删除“启动”文件夹中的快捷方式。

You can put it in startup folder by adding shortcut to the C:\\Documents and Settings\\< username>\\Start Menu\\Programs\\Startup folder or the startup key in windows registry . 通过将快捷方式添加到C:\\ Documents and Settings \\ <用户名> \\ Start Menu \\ Programs \\ Startup文件夹或Windows注册表中的启动键,可以将其放在启动文件夹中。 It will get started, unless user deletes the shortcut/registry entry. 除非用户删除快捷方式/注册表项,否则它将开始。 What is reliable for you? 什么对您来说可靠?

You can use GPEDIT.MSC command. 您可以使用GPEDIT.MSC命令。 In the Local Computer Policy --> UserConfiguration --> Windows Settings --> Scripts (Logon/ Logoff). 在本地计算机策略->用户配置-> Windows设置->脚本(登录/注销)中。 You can add following Logon script (VB Script) 您可以添加以下登录脚本(VB脚本)

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "app.exe", 9, true

// The script will try to load the application from Windows\\System folder. //脚本将尝试从Windows \\ System文件夹加载应用程序。 So make sure that you put your exe @ \\Windows\\System folder first. 因此,请确保首先将exe @ \\ Windows \\ System文件夹放入。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM