Windows 设置开机启动(常用软件、jupyter、redis)
两种方式, 一种是开机进入桌面后手动管理, 另外一种是随着Windows启动而启动。
一、手动方式
新建一键启动.bat:
@echo off
mode con lines=30 cols=100
title= 一键启动
:main
cls
color 2e
echo %time%
echo.Martin's Blog https://javakam.github.io
color 1f
echo.-----------------------------------------------------------
echo Starting QQ...
start "" "D:\Program Files (x86)\Tencent\QQ\Bin\QQScLauncher.exe"
echo Starting WeChat...
start "" "D:\Program Files (x86)\Tencent\WeChat\WeChat.exe"
echo Starting QQBrowser...
start "" "D:\Program Files (x86)\Tencent\QQBrowser\QQBrowser.exe"
二、自动启动
把需要自动启动的bat或vbs放到Windows开机启动目录下C:\Users\ChangBao\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup (另外一个目录:C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp, 没测试):
jupyter_startup.vbs为jupyter notebook:
Dim wsh
Set wsh = createobject("wscript.Shell")
'1. 使用配置文件启动 jupyter_notebook_config.py
'wsh.run "cmd /c jupyter notebook --no-browser", 0, true
'2. 直接进入路径启动[推荐]
wsh.run "cmd /c jupyter notebook --notebook-dir='C:\fastwork\Python\JupyterNotebook' --no-browser", 0, true
Set wsh = Nothing
附:
jupyter设置指定目录:cmd执行jupyter notebook --generate-config后, 会生成一个upyter_notebook_config.py文件, 并在该文件在中指定位置 👉 c.NotebookApp.notebook_dir = r'C:\fastwork\Python\JupyterNotebook' 注意路径前面的r!!! 或者 有跟简单的直接改用主动声明路径的方式 wsh.run "cmd /c jupyter notebook --notebook-dir='C:\fastwork\Python\JupyterNotebook' --no-browser", 0, true
service_redis_startup.vbs为启动Redis的快捷方式, 原路径为:
service_start.bat:
::启动redis的命令
@echo off
::这是简单的输出,相当于java中的system.out.println()
echo redis-server start......
::设置启动窗口的标题
title redis-server
::定义一个变量ENV_HOME
set ENV_HOME="C:\fastwork\Redis"
C:
::设置启动窗口的颜色
color 0a
cd %ENV_HOME%
redis-server.exe redis.windows.conf
exit
service_redis_startup.vbs:
set ws=wscript.createobject("wscript.shell")
ws.run "service_start.bat /start",0
✨ 使用vbs的好处是不会启动cmd窗口, 而是后台执行后进程留存在任务管理器中, 防止不小心关闭cmd窗口。上面两个vbs启动的任务对应为:
jupyter notebook
Redis服务

浙公网安备 33010602011771号