1、显示yyyymmddhh24:mi:ss格式的时间
@echo off
set todayDate=%date:~0,4%%date:~5,2%%date:~8,2%%time:~0,8%
echo %todayDate%
pause
2、打开某个目录
@echo off
::待打开的目录(目录中若含有空格须要用缩写的形式表示)
set mydir=D:\
start %mydir%
3、用notepad++打开某个文本
@echo off
::文本文件的完整路径
set file_fullName=D:\a.txt
::文本编辑器的完整路径
set textEditTool_fullName=C:\Program files\Notepad++\notepad++.exe
run "%textEditTool_fullName%" "%file_fullName%"
4、清空某个目录下所有非doc文件
@echo off
set dest_dir="D:\dir1"
for /f "delims=" %%I in ('dir %dest_dir% /a-d /s /b') do (
if not %%~xI==.doc (
del /f /q "%%~sI"
)
)
::删除空目录
for /f "delims=" %%J in ('dir %dest_dir% /ad /s /b') do (
rd /s /q "%%~sJ"
)
pause
5、keytool将证书导入当前目录下的my.keystore文件
keytool -import -keystore %~dp0my.keystore -storepass 123456 -file %1 -alias %1 -noprompt
6、jarsigner签名脚本(sign_jar.bat)
set file_fullName=%~dp0%myKeystore
jarsigner -keystore "%file_fullName%" -storepass 123456 %1 myself
7、将sign_jar.bat添加到右键菜单中
@green_Install.bat
@echo off
set program_fullName=%~dp0%sign_jar.bat
set reg_name=Sign_jar
set reg_value=Sign this jar
::这是只对jar文件才会生效
reg add "HKCR\jarfile\shell\%reg_name%" /ve /d "%reg_value%" /f
reg add "HKCR\jarfile\shell\%reg_name%\command" /ve /d "%program_fullName% %%1" /f
:: 下面是通用菜单(不针对特殊文件格式的)
:: reg add "HKCR\*\shell\%reg_name%" /ve /d "%reg_value%" /f >nul
:: reg add "HKCR\*\shell\%reg_name%\command" /ve /d "%program_fullName% %%1" /f >nul
:: reg add "HKCR\Folder\shell\%reg_name%" /ve /d "%reg_value%" /f >nul
:: reg add "HKCR\Folder\shell\%reg_name%\command" /ve /d "%program_fullName% %%1" /f >nul
@green_Uninstall.bat
@echo off
set reg_name=Sign_jar
reg delete "HKCR\jarfile\shell\%reg_name%" /f >nul 2>nul
rem reg delete "HKCR\*\shell\%reg_name%" /f >nul 2>nul
rem reg delete "HKCR\Folder\shell\%reg_name%" /f >nul 2>nul