自定义脚本加入开机自启动
In this guide we will show you how to enable programs or custom scripts to run when Windows boots up. You may prefer that your Outlook opens up every time you log in to your computer in the morning at work, or you may want a custom batch file to run every time the desktop loads. Whatever your needs, this guide will show several convenient ways for configuring this behavior. We will also take a look at other methods programs use to run at boot and how to disable them.
在本指南中,我们将向您展示如何在Windows启动时启用程序或自定义脚本。 您可能希望每次工作时早上登录计算机时都打开Outlook,或者希望每次加载桌面时都运行自定义批处理文件。 无论您有什么需要,本指南都会显示几种方便的方式来配置此行为。 我们还将介绍程序在启动时用于运行的其他方法以及如何禁用它们。
任务计划程序 (Task Scheduler)
In recent versions of Windows, we geeks no longer have to configure a hack or workaround to make a program run at boot, because can use the Task Scheduler utility provided in Windows. It’s best to use this method when at all possible, because this utility was specifically made for this purpose. Task Scheduler gives you a variety of options, such as whether or not to run the application with escalated privileges and setting the application to run only when certain conditions are met (AC power, network connection, etc).
在Windows的最新版本中,由于可以使用Windows中提供的Task Scheduler实用程序,因此我们极客不再需要配置hack或解决方法以使程序在启动时运行。 最好尽可能使用此方法,因为此实用程序是专门为此目的而设计的。 Task Scheduler提供了多种选项,例如是否以升级的特权运行应用程序,以及将应用程序设置为仅在满足某些条件(交流电源,网络连接等)时运行。
To show you an example of what you can do with Task Scheduler, we will go through the steps required to make Event Viewer open up when you log in.
为了向您展示您可以使用Task Scheduler进行操作的示例,我们将介绍登录时打开Event Viewer所需的步骤。
Go to the Start menu, type “Task Scheduler” and select it from the search results.
转到“开始”菜单,键入“任务计划程序”,然后从搜索结果中选择它。
Task Scheduler can also be accessed in the Control Panel under Administrative Tools.
也可以在“控制面板”中“管理工具”下访问“任务计划程序”。
In the right side of the Task Scheduler menu, under Actions, select “Create Task.”
在“任务计划程序”菜单的右侧,在“操作”下,选择“创建任务”。
After clicking on that, you will see the following menu:
单击该菜单后,您将看到以下菜单:
In the screenshot above, we have already put in a name and description for the task we’re creating. The only other thing we have done is check the box “Run with highest privileges.” Launching certain applications such as Event Viewer will typically result in a User Account Control prompt, unless you have UAC disabled on your system. When scheduling a task that requires administrator privileges, be sure to check this box, otherwise you will see an error in the notification area (lower right corner of the taskbar) and have to manually allow it.
在上面的屏幕截图中,我们已经为正在创建的任务添加了名称和描述。 我们要做的唯一另一件事是选中“以最高特权运行”框。 启动某些应用程序(例如“事件查看器”)通常会导致出现“用户帐户控制”提示,除非您在系统上禁用了UAC。 安排需要管理员权限的任务时,请务必选中此框,否则您将在通知区域(任务栏的右下角)看到错误,必须手动允许它。
Once you have filled out a name and description, click the “Triggers” tab, and then click “New.” You will be presented with a menu like the one below.
填写名称和描述后,单击“触发器”选项卡,然后单击“新建”。 您将看到与下面类似的菜单。
In this menu, under “Begin the task:” select “At log on.” Choose which user you would like the task to run for at log on, and configure any of the applicable advanced settings you would like. With the settings in the above screenshot, Event Viewer will run at every future log on as soon as user ‘geek’ logs in.
在此菜单的“开始任务:”下,选择“登录时”。 选择您要在登录时运行任务的用户,然后配置所需的任何适用的高级设置。 使用上面的屏幕截图中的设置,事件查看器将在用户“极客”登录后立即在以后每次登录时运行。
After you are finished configuring the new trigger, click OK and then select the “Actions” tab. Click “New” to make a new action.
完成新触发器的配置后,单击“确定”,然后选择“操作”选项卡。 单击“新建”以执行新操作。
Choose “Start a program” under the Action menu and then click “Browse” to point the new task to the program you would like it to start. In the example above, we have selected Event Viewer. If there are any arguments you need to run with your program, you can add those as well. For Event Viewer, none will be required, but other programs such as gaming servers will rely on them.
在“操作”菜单下选择“启动程序”,然后单击“浏览”以将新任务指向您要启动的程序。 在上面的示例中,我们选择了事件查看器。 如果您的程序需要运行任何参数,则也可以添加这些参数。 对于事件查看器,将不需要任何内容,但是其他程序(例如游戏服务器)将依赖它们。
Click OK to exit out of the Actions menu. The “Conditions” and “Settings” tabs can be left alone, but feel free to check them out for a few more options – most of which are irrelevant for a task that runs a program at log on.
单击确定退出“操作”菜单。 “条件”和“设置”选项卡可以保留,但可以随时检查它们以获取更多选项-其中大多数与在登录时运行程序的任务无关。
Click OK on the Create Task menu, and you are finished.
在“创建任务”菜单上单击“确定”,您已完成。
启动文件夹 (Startup Folder)
Another way to set a program or script to run at log on is using the Startup folder. You can access this folder in Windows 7 and previous versions of Windows by going to Start > All programs > Startup. On Windows 8 and previous versions, Startup can also be accessed in Explorer by browsing to “C:\Users\username\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup” (replacing ‘username’ with the name of your user).
设置程序或脚本在登录时运行的另一种方法是使用Startup文件夹。 您可以进入Windows>所有程序>启动,在Windows 7和Windows早期版本中访问此文件夹。 在Windows 8和早期版本上,也可以通过浏览到“ C:\ Users \ username \ AppData \ Roaming \ Microsoft \ Windows \ Start Menu \ Programs \ Startup”在资源管理器中访问“启动”(用您的名称替换“用户名”用户)。
To use the Startup folder to configure a program to run at boot, just make a shortcut to said program (Right click > Send to > Desktop) and put that shortcut in the Startup folder. Some programs use this method as their way of configuring themselves to run at start. If you have a program that keeps launching whenever you log in, there may be a shortcut to that program in the Startup folder.
要使用Startup文件夹配置程序以在启动时运行,只需为该程序创建一个快捷方式(右键单击>发送到>桌面),然后将该快捷方式放在Startup文件夹中。 某些程序将这种方法用作配置自己以使其在启动时运行的方式。 如果您有一个程序在每次登录时始终启动,则“启动”文件夹中可能会存在该程序的快捷方式。
在启动时运行自定义脚本 (Running Custom Scripts at Startup)
Along with running programs at log on, you can also use Task Scheduler or the Startup folder to run custom batch scripts. Batch files contain commands that would normally be run in a command-line window. For example, the following code tells Windows to map a network share located on 192.168.1.1 to drive Z:.
除了在登录时运行程序外,还可以使用“任务计划程序”或“启动”文件夹来运行自定义批处理脚本。 批处理文件包含通常在命令行窗口中运行的命令。 例如,以下代码告诉Windows将位于192.168.1.1上的网络共享映射到驱动器Z:。
net use z: \\192.168.1.1\share /USER:geek /P:Yes
net use z: \\192.168.1.1\share /USER:geek /P:Yes
To execute this line of code at startup, simply paste it into a text document and save the file as .bat. Place the .bat file in the Startup folder or use Task Scheduler to have your computer execute the line(s) of code whenever the specified user logs in.
要在启动时执行此行代码,只需将其粘贴到文本文档中,然后将文件另存为.bat。 将.bat文件放置在Startup文件夹中,或使用Task Scheduler使您的计算机在指定的用户登录时执行代码行。
禁止程序在启动时运行 (Disabling programs from running at boot)
There are a few ways that a program can configure itself to run at boot. The methods mentioned above are two of them, and after reading that you should have a good idea on how to disable programs that use those two methods. You should also see this guide for help with disabling programs that use the registry or other methods to run at boot.
程序可以通过几种方式将自身配置为在引导时运行。 上面提到的方法是其中两种,阅读完之后,您应该对如何禁用使用这两种方法的程序有个好主意。 您还应该参阅本指南 ,以获取有关禁用使用注册表或其他方法在启动时运行的程序的帮助。
翻译自: https://www.howtogeek.com/138159/how-to-enable-programs-and-custom-scripts-to-run-at-boot/
自定义脚本加入开机自启动