有个exe文件。非安装版
比如a.exe吧我想让它随电脑启动的时候自动启动a.exe应该怎么设置一下??

解决方案 »

  1.   

     
    using Microsoft.Win32;
    public static bool SetAutoRun(string keyName,string filePath)
            {
                try
                {
                    RegistryKey runKey=Registry.LocalMachine.OpenSubKey(@"\SOFTWARE\Microsoft\Windows\CurrentVersion\Run",true);
                    runKey.SetValue(keyName,filePath);
                    runKey.Close();
                }
                catch
                {
                    return false;
                }
                return true;
            }
    test: SetAutoRun("myexe","c:\\text.exe"); 另外也可以写成服务,不过服务的话一般是在后台执行的,没有程序界面。
      

  2.   

    放到注册表的目录:
    SOFTWARE\Microsoft\Windows\CurrentVersion\Run
      

  3.   

    1、拖快捷方式到程序菜单的启动项里
    2、写注册表到系统启动项run里
    3、新建计划任务,开机启动
    4、组策略gpedit.msc,在计算机配置(用户配置)/windows设置/启动中添加一个脚本
    5、写windows服务我就知道这几种,下面补充你这个问题应该发到windows专区去