需求:每次開機都需要啟動Redis、QQ、IDEA等等好幾個軟件,手動點擊比較無趣、浪費勞動力,所以通過自定義bat文件,進行批量啟動。
唯獨啟動到Redis時出現問題,下面是在bat里運行的路徑:
D:\Redis\Redis-x64-3.2.100\redis-server.exe redis.windows.conf
發現啟動報錯提示:
Invalid argument during startup: Failed to open the .conf file: redis.windows.conf CWD=C:\Users\*******
報錯的原因是“redis-server.exe”程序需要讀取一個配置文件“redis.windows.conf”文件。由於后面這個文件是相對路徑,所以批處理找不到。解決方法是使用絕對路徑:
D:\Redis\Redis-x64-3.2.100\redis-server.exe D:\Redis\Redis-x64-3.2.100\redis.windows.conf
附送自定義批處理模板:
echo 啟動:QQ
::利用ping命令延遲,單位毫秒
ping 1.1.1.0 -n 1 -w 1000 > nul
start /min "" "D:\軟件\QQ\Bin\QQScLauncher.exe"
echo 啟動:Redis
ping 1.1.1.0 -n 1 -w 1000 > nul
::Redis啟動的時候需要加載配置
D:\Redis\Redis-x64-3.2.100\redis-server.exe D:\Redis\Redis-x64-3.2.100\redis.windows.conf