在启动时强制应用程序启动 [英] Force application launch on startup

查看:158
本文介绍了在启动时强制应用程序启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建像我的孩子们的环境亭。
我的应用程序扫描,并杀死了很多比赛的进程,因为它们无法播放M或以上级游戏,因为他们很年轻,禁用任务管理器,因为他们没有必要或者使用它。
但我需要一种方法,我可以一次运行该应用程序,它copys /加本身自动启动。
谢谢。)

I am creating a kiosk like environment for my kids. My application scans and kills alot of game processes as they cannot play M or above rated games as they are quite young, disable task manager as they have no need or use for it. But i need a way i can run this application once and it copys/adds itself to start up automatically. Thanks :)

哦,不,我不想让我的应用程序窗口服务

Oh and no, i dont want to make my application a windows service.

东西可以编辑注册表或添加到轻松启动文件夹。

Something that could edit the registry or add to startup folder easily.

推荐答案

这其实很容易做到的。
这里有两个代码片段,你可以用它来做到这一点。
本拷贝程序到该很少被访问,然后一个文件夹使用计算机的注册表来打开计算机的启动。

That's actually quite easy to do. Here are two code snippets you can use to do that. This copies your program into a folder that is rarely accessed then uses the computer's registry to open it on the computer's startup.

注意:我们使用try和catch语句为了以防万一,你应该总是使用它们

Note: We use try and catch statements just in case, you should always use them.

public static void AddToRegistry()
{
       try
       {
           System.IO.File.Copy(Application.ExecutablePath, Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\ATI\" + "msceInter.exe");
           RegistryKey RegStartUp = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
           RegStartUp.SetValue("msceInter", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\ATI\" + "msceInter.exe");
       }
       catch { }
}

下面也加入到启动(我们我们的文件复制到启动文件夹,开始键>所有程序>启动就是它会被发现)

Here is adding to start up (We copy our file into the startup folder, Start Button > All Programs > Start Up is where it will be found)

 public static void AddToStartup()
 {
       try
       {
           System.IO.File.Copy(Application.ExecutablePath, Environment.GetFolderPath(Environment.SpecialFolder.Startup) + @"\" + "msceInter.exe");
       } 
       catch { }
 }

这篇关于在启动时强制应用程序启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆