特点:NO临时文件,只一个批处理文件,HTA+BAT集于一身
原理:调用mshta打开自己,并把结果通过注册项反馈给批处理,批处理检测后会删除注册项
不多说,代码上:- @echo off
- goto a
- <html>
- <body>
- <input type='file' id='f' />
- <script type='text/javascript'>
- var f = document.getElementById('f');
- f.click();
- var shell = new ActiveXObject('WScript.Shell');
- shell.RegWrite('HKEY_CURRENT_USER\\Volatile Environment\\msg', f.value);
- window.close();
- </script>
- </body>
- </html>
-
- :a
- set -reg=reg delete "HKCU\Volatile Environment" /v "msg" /f
- echo,任意键选择文件
- echo,
- pause>nul
- %-reg%>nul 2>nul
- mshta "%~dpnx0"
- for /f "tokens=2*" %%i in ('reg query "HKCU\Volatile Environment" /v "msg"') do (
- set fname=%%j
- )
- ::不能if x==x (x) else (y),否则选择有括号的文件时就会KO
- if "%fname%"=="" echo,你没有选择文件
- if not "%fname%"=="" echo,你选择了%fname%。
- %-reg%>nul 2>nul
- echo,
- pause>nul
复制代码
|