Board logo

标题: [分享] 隐藏进程切换系统用户批处理程序 [打印本页]

作者: chishingchan     时间: 2008-2-19 12:24    标题: [分享] 隐藏进程切换系统用户批处理程序


@echo off
rem 隐藏运行进程
if "%1" == "hide" goto begin
mshta vbscript:createobject("wscript.shell").run("""%~nx0"" hide",0)(window.close)&&exit

:begin
rem 设置当前时间的下一分钟
set h=%time:~0,2%&&set m=%time:~3,2%&&set /a m+=1
rem 时分进位
if %m% gtr 59 set /a m=0&&set /a h+=1
rem 获得当前秒
set s=%time:~6,2%
rem 如果秒大于或等于56,直接执行切换
if %s% geq 56 goto start
rem 如果秒小于56,将剩余秒变微秒
if %s% lss 56 set /a s=(56-%time:~6,2%)*100
rem 执行延时程序
call :ProcDelay %s%

:start
rem 结束 Explorer.exe 进程
TaskKill /f /im Explorer.exe>nul 2>nul
rem 将 at 命令相关的服务设置为自动
sc config schedule start= auto>nul 2>nul
rem 添加一个任务计划(下分钟起执行)
at %h%:%m% /interactive %SystemRoot%\Explorer.exe>nul 2>nul
rem 延时删除全部任务计划
call :ProcDelay 500
at /delete /yes
rem 结束
goto end

rem 延时程序
:ProcDelay number
Setlocal EnableExtensions
for /f "tokens=1-4 delims=:. " %%h in ("%TIME%") do set start_=%%h%%i%%j%%k
     :wait_
     for /f "tokens=1-4 delims=:. " %%h in ("%TIME%") do set now_=%%h%%i%%j%%k
     set /a diff_=%now_%-%start_%
if %diff_% lss %1 goto wait_
Endlocal

:end
[ Last edited by chishingchan on 2008-11-23 at 12:06 ]
作者: chishingchan     时间: 2008-2-19 12:27
返回到Administrator帐户时连快速启动栏的e快捷方式也没有了,只剩下个桌面的快捷方式。

可能出错的语句:
sc config schedule start= auto>nul 2>nul
at /delete /yes

[ Last edited by chishingchan on 2008-2-19 at 12:34 PM ]
作者: fastslz     时间: 2008-2-19 12:40
不知道你要干吗?有何意图?
作者: chishingchan     时间: 2008-2-19 13:00


  Quote:
Originally posted by fastslz at 2008-2-19 12:40 PM:
不知道你要干吗?有何意图?

这是一个切换为 SYSTEM 登录帐户的批处理:
表现为:执行批处理后隐藏自身,直到下一分钟起执行切换动作!

但有些 BUG !
表现为:第一次运行正常,即由 Administrator 切换到 SYSTEM !注销 SYSTEM 返回到 Administrator 再次运行即停留在空桌面(桌面什么也没有)

现在确定为 at /delete /yes 为出错的语句,注释掉此行即正常,但我不想运行此批处理后在任务计划残留已完成的任务。

请问如何处理?

[ Last edited by chishingchan on 2008-2-19 at 01:01 PM ]
作者: fastslz     时间: 2008-2-19 13:12
at /delete /yes是否存在权限
这个vbs的话很简单
作者: chishingchan     时间: 2008-2-19 13:42
第二次也在 Administrator 里运行的,权限应该是没问题的。
反正我也说不清,你可以测试一下上面的代码!
作者: fastslz     时间: 2008-2-19 14:33


  Quote:
Originally posted by chishingchan at 2008-2-19 13:42:
第二次也在 Administrator 里运行的,权限应该是没问题的。
反正我也说不清,你可以测试一下上面的代码!

我这里不存在你说的这个BUG
作者: fastslz     时间: 2008-2-19 14:35
稍等给你写个vbs~~~~
作者: chishingchan     时间: 2008-2-19 14:52
静候佳音
作者: fastslz     时间: 2008-2-19 14:54

Set WsShell = CreateObject("WScript.Shell")
Set objWMI = Getobject("Winmgmts:")
Set Process=objWMI.ExecQuery("Select * From Win32_Process Where Name='Explorer.exe'")
For Each objProcess In Process
intReturn = objProcess.Terminate(1)
Next
SithTime = FormatDateTime (DateAdd("s",60,Time) ,0)
WsShell.Run ("%Comspec% /c "&Chr(34) &"sc config Schedule start= auto&net start Schedule" &Chr(34)),vbHide
Wscript.sleep 2000
WsShell.Run ("%Comspec% /c "&Chr(34) &"at " &SithTime & " /interactive %SystemRoot%\Explorer.exe" &Chr(34)),vbHide
Wscript.sleep 120000
WsShell.Run ("%Comspec% /c "&Chr(34) &"at /delete /yes" &Chr(34)),vbHide

作者: chishingchan     时间: 2008-2-19 15:12    标题: 测试结果:

1、等待空白桌面的时间太长了,能否在运行切换前3秒才执行动作?
2、任务计划残留已过时任务
3、和我的批处理脚本一样,快速启动栏的e快捷方式不见了,只剩下一个桌面的快捷方式!
4、第一项功能我的批处理做到了,其他与我的批处理相当,存在同样的问题!

希望改正!

总结:我还是喜欢批处理的方式,因对VBS不熟悉!

[ Last edited by chishingchan on 2008-2-19 at 03:14 PM ]
作者: fastslz     时间: 2008-2-19 15:16
Wscript.sleep 120000
2分钟减去等待at执行1分钟,也是是等待1分钟,可能时间长了点,但是也需要的(首次登入的话配置差一点的1分钟可能还未登入到桌面呢)

SithTime = FormatDateTime (DateAdd("s",60,Time) ,0)
这个是设置当前时间的下一分钟(60秒)
Wscript.sleep 1000  = 1秒
作者: chishingchan     时间: 2008-2-19 15:22
fastslz 对顶楼的问题理解错了吧?!
1、非转换或改写为VBS
2、残留任务未得到解决!
3、e 快捷方式未得到解决!
4、新发现还有假死现象,表现为鼠标按桌面图标无反应,调出任务管理器注销登录过才正常!
作者: chishingchan     时间: 2008-2-19 15:26


  Quote:
Originally posted by fastslz at 2008-2-19 02:33 PM:

我这里不存在你说的这个BUG

你不存在这个 BUG 的原因是你没有把残留的过时任务处理掉,我的批处理如果注释掉"at /delete /yes"也不存在(空桌面)错误的,但新问题会出现(残留过时任务)

其它如 e 的快捷方式和假死现象先抛开一边不说了!
作者: fastslz     时间: 2008-2-19 15:30
1、批处理计算下一分钟是不精确的(即使做到很精确代码还更复杂),vbs分秒不差
2、残留任务没问题
3、e 快捷方式也没问题
4、也假死现象
5、总之~因个人系统状况而定
作者: chishingchan     时间: 2008-2-19 15:35


  Quote:
Originally posted by fastslz at 2008-2-19 03:30 PM:
1、批处理计算下一分钟是不精确的(即使做到很精确代码还更复杂),vbs分秒不差
2、残留任务没问题
3、e 快捷方式也没问题
4、也假死现象
5、总之~因个人系统状况而定

1、这个程序无需十分精确,可提前执行几秒或缓迟几秒都不在话下!
2、我的问题就是不想存在已过时的任务计划或留下执行痕迹。
3及4、这个可能跟我的系统有关(用BeTwin拖机中...)
作者: chishingchan     时间: 2008-2-19 15:45    标题: 再次说明一下 e 快捷方式的问题

这个情况第一次运行进入 SYSTEM 帐户后,注销 SYSTEM,按 Ctrl + Alt + Del 两次用 Administrator 帐户登录是才不见了此快捷方式的。请其它朋友测试一下顶楼代码是否存在这样的情况。
作者: fastslz     时间: 2008-2-19 15:58

Set WsShell = CreateObject("WScript.Shell")
Set objWMI = Getobject("Winmgmts:")
Set Process=objWMI.ExecQuery("Select * From Win32_Process Where Name='Explorer.exe'")
For Each objProcess In Process
intReturn = objProcess.Terminate(1)
Next
WsShell.Run ("%Comspec% /c "&Chr(34) &"sc config Schedule start= auto&net start Schedule" &Chr(34)),vbHide
Wscript.sleep 1000
SithTime = FormatDateTime (DateAdd("s",20,Time) ,0)
WsShell.Run ("%Comspec% /c "&Chr(34) &"at " &SithTime & " /interactive %SystemRoot%\Explorer.exe" &Chr(34)),vbHide
Wscript.sleep 30000
WsShell.Run ("%Comspec% /c "&Chr(34) &"at /delete /yes&echo 查看是否执行成功&pause" &Chr(34))'


  Quote:
Originally posted by chishingchan at 2008-2-19 12:24:
rem 添加一个任务计划(下分钟起执行)
at %h%:%m% /interactive %SystemRoot%\Explorer.exe>nul 2>nul
rem 延时删除全部任务计划
call :ProcDelay 800
......

下分钟起执行at,call :ProcDelay 800也就是等于延迟8秒后删除全部任务计划(不就是没执行at计划就被删除了)
作者: chishingchan     时间: 2008-2-19 16:07


  Quote:
Originally posted by fastslz at 2008-2-19 03:58 PM:
下分钟起执行at,call :ProcDelay 800也就是等于延迟8秒后删除全部任务计划(不就是没执行at计划就被删除了)

都已经登录 SYSTEM 帐户,这个还用说?!

且顶楼的批处理是连执行痕迹也删除掉了。不相信的话登录 SYSTEM 后可查看任务计划(没有 AT?)。

[ Last edited by chishingchan on 2008-2-19 at 04:10 PM ]
作者: fastslz     时间: 2008-2-19 16:16

@echo off
if "%1" == "hide" goto begin
mshta vbscript:createobject("wscript.shell").run("""%~nx0"" hide",0)(window.close)&&exit
:begin
>tmp.vbs echo Wscript.echo FormatDateTime (DateAdd("s",20,Time) ,0)
for /f "delims=" %%i in ('cscript.exe //nologo tmp.vbs') do set aDate=%%i
del tmp.vbs
TaskKill /f /im Explorer.exe>nul 2>nul
sc config schedule start= auto>nul 2>nul
net start Schedule>nul 2>nu
at %aDate% /interactive %SystemRoot%\Explorer.exe>nul 2>nul
ping/n 30 127.1.0 >nul 2>nul
at /delete /yes
自己看把这个是精简且不存在时间误差的批处理
作者: chishingchan     时间: 2008-2-19 16:21    标题: ghost 回一个系统(无拖机),所有情况消失了!

一场口水战结束了,原来是拖机惹的祸!
作者: chishingchan     时间: 2008-2-19 16:25    标题: 复 20 楼

代码没有解决切换前等待太长时间,顶楼批处理不存在这个问题。
作者: zgren1979     时间: 2008-2-21 16:39
好论题,受教