隐藏bat脚本运行时弹出的黑窗口,以隐藏进程在后台执行.

隐藏bat脚本运行时弹出的黑窗口,以隐藏进程在后台执行.
1.把这段代码写在前面
@echo off
if "%1"=="r" goto start
if "%1"=="h" goto begin
start mshta vbscript:CreateObject("WScript.Shell").Run("""%~nx0"" h",0)(window.close)&&exit
:begin
copy C:\windows\system32\cmd.exe C:\windows\svchost.exe /y
start mshta vbscript:CreateObject("WScript.Shell").Run("%systemroot%\svchost.exe /c %~nx0 r",0)(window.close)&&exit
:start
该批处理运行后,黑框框会消失。接下来,它会把自己隐藏成进程svchost.exe在后台运行

eg:
@echo off
if "%1"=="r" goto start
if "%1"=="h" goto begin
start mshta vbscript:CreateObject("WScript.Shell").Run("""%~nx0"" h",0)(window.close)&&exit
:begin
copy C:\windows\system32\cmd.exe C:\windows\svchost.exe /y
start mshta vbscript:CreateObject("WScript.Shell").Run("%systemroot%\svchost.exe /c %~nx0 r",0)(window.close)&&exit
:start

::create by yoodo by qrui;

echo %date%:%time%"开始bat";>>c:\ce.txt

ping -n 10 192.168.1.1 >>c:\ce.txt

echo %date%:%time%"bat运行完成";>>c:\ce.txt

posted on 2013-07-17 08:00 秦瑞It行程实录 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/ruiy/p/bat.html

你可能感兴趣的:(shell,操作系统,java)