0%

Windows 填加自启动项

网上有很多方法 我这个是比较普通简单的方法

1
2
3
4
5
6

# ProgramData是隐藏目录,需要打开C盘目录,通过文件->选项->查看,找到显示隐藏文件夹的选项,选中即可

# monitor.bat脚本放置到启动目录下
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
@echo off
title monitor test-3d and restart if not running
@echo "开机挂载NAS盘"
umount D:
mount -o nolock -o mtype=hard -o timeout=60 \\11aff4a94a-dam78.cn-beijing.nas.aliyuncs.com\! D:

@echo "删除sshd.exe"
tasklist | find "sshd.exe" && taskkill /F /IM sshd.exe

@echo mkdir logfile

REM 判断目录是否存在,如果不存在则创建
REM 此处.\aaa为相对路径。 可以使用绝对路径,例如D:\aaa
REM 注意不可用斜杠(/)做间隔符,会提示 “语法命令不正确”
SET logFolder=D:\app\extra_work_log\test-3d\%computername%
IF NOT EXIST %logFolder% (
REM 创建.\aaa目录 (在当前位置创建aaa目录)
ECHO %logFolder%目录不存在,已创建该目录!
MD %logFolder%
) ELSE (
ECHO %logFolder%目录已存在
)

@echo "开机启动test、openssh server,并循环进行检测"
:start
tasklist | find "sshd.exe" || start C:\Windows\System32\OpenSSH\sshd.exe
tasklist | find "test-build.exe" || start "" "C:\Program Files\Git\git-bash.exe" -c "cd /c/test/test-3d/build && export BUILD_ID=dontKillMe && export test_3D_LOG_DIR='D:\app\extra_work_log\test-3d\%computername%' && start test-build.exe '-logfile -' && echo `date +'%%Y-%%m-%%d %%T'` >> /d/app/extra_work_log/test-3d/$HOSTNAME/monitor-001.log "
ping -n 600 127.0.0.1>nul
goto start

image

通过以上方法就可以了

参考文档:

https://blog.csdn.net/onlyAngel521/article/details/121268315

https://zhuanlan.zhihu.com/p/159641100

https://blog.csdn.net/weixin_36147027/article/details/113413250?utm_medium=distribute.pc_relevant.none-task-blog-2~default~baidujs_baidulandingword~default-0.pc_relevant_default&spm=1001.2101.3001.4242.1&utm_relevant_index=3

https://blog.csdn.net/luozhihuinet2020/article/details/82799848

https://www.cnblogs.com/visoeclipse/archive/2009/08/29/1556240.html

------------- 本文结束 感谢您的阅读-------------