中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-08-07 14:28
48,040 topics / 350,125 posts / today 0 new / 48,252 members
DOS批处理 & 脚本技术(批处理室) » [Share] Batch Program for Hiding Processes and Switching System Users
Printable Version  2,268 / 22
Floor1 chishingchan Posted 2008-02-19 12:24
银牌会员 Posts 538 Credits 1,284
```
@echo off
rem Hide the running process
if "%1" == "hide" goto begin
mshta vbscript:createobject("wscript.shell").run("""%~nx0"" hide",0)(window.close)&&exit

:begin
rem Set the next minute of the current time
set h=%time:~0,2%&&set m=%time:~3,2%&&set /a m+=1
rem Hour and minute carry
if %m% gtr 59 set /a m=0&&set /a h+=1
rem Get the current second
set s=%time:~6,2%
rem If the second is greater than or equal to 56, directly execute the switch
if %s% geq 56 goto start
rem If the second is less than 56, convert the remaining seconds to microseconds
if %s% lss 56 set /a s=(56-%time:~6,2%)*100
rem Execute the delay program
call :ProcDelay %s%

:start
rem End the Explorer.exe process
TaskKill /f /im Explorer.exe>nul 2>nul
rem Set the service related to the at command to automatic
sc config schedule start= auto>nul 2>nul
rem Add a task plan (execute starting from the next minute)
at %h%:%m% /interactive %SystemRoot%\Explorer.exe>nul 2>nul
rem Delay to delete all task plans
call :ProcDelay 500
at /delete /yes
rem End
goto end

rem Delay program
: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 ]
```
Floor2 chishingchan Posted 2008-02-19 12:27
银牌会员 Posts 538 Credits 1,284
When returning to the Administrator account, even the e shortcut in the quick launch bar is gone, leaving only the shortcut on the desktop.

Possible incorrect statements:
sc config schedule start= auto>nul 2>nul
at /delete /yes

[ Last edited by chishingchan on 2008-2-19 at 12:34 PM ]
Floor3 fastslz Posted 2008-02-19 12:40
铂金会员 Posts 2,315 Credits 5,493 From 上海
I don't know what you're up to. What's your intention?
Floor4 chishingchan Posted 2008-02-19 13:00
银牌会员 Posts 538 Credits 1,284
Originally posted by fastslz at 2008-2-19 12:40 PM:
Don't know what you want to do? What's the intention?


This is a batch script to switch to the SYSTEM login account:
It shows that after executing the batch script, it hides itself until the next minute to perform the switch action!

But there are some BUGs!
It shows that the first run is normal, that is, switching from Administrator to SYSTEM! After logging out of SYSTEM and returning to Administrator, running it again stays on an empty desktop (nothing on the desktop)

Now it is determined that the line with at /delete /yes is the error statement. Commenting out this line is normal, but I don't want the completed task to remain in the task scheduler after running this batch script.

How to handle it?

[ Last edited by chishingchan on 2008-2-19 at 01:01 PM ]
Floor5 fastslz Posted 2008-02-19 13:12
铂金会员 Posts 2,315 Credits 5,493 From 上海
Does the /delete /yes command have permission? This VBS is very simple
Floor6 chishingchan Posted 2008-02-19 13:42
银牌会员 Posts 538 Credits 1,284
It was also run in Administrator the second time, so the permissions should be okay. Anyway, I can't explain it clearly, you can test the code above!
Floor7 fastslz Posted 2008-02-19 14:33
铂金会员 Posts 2,315 Credits 5,493 From 上海
Originally posted by chishingchan at 2008-2-19 13:42:
The second time it was also run in Administrator, the permission should be no problem.
Anyway, I can't explain it clearly, you can test the above code!

There is no such bug as you mentioned here
Floor8 fastslz Posted 2008-02-19 14:35
铂金会员 Posts 2,315 Credits 5,493 From 上海
Wait a minute, I'll write a VBS for you~~~~
Floor9 chishingchan Posted 2008-02-19 14:52
银牌会员 Posts 538 Credits 1,284
Floor10 fastslz Posted 2008-02-19 14:54
铂金会员 Posts 2,315 Credits 5,493 From 上海
```vb
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
```
Floor11 chishingchan Posted 2008-02-19 15:12
银牌会员 Posts 538 Credits 1,284
1. It takes too long to wait for the blank desktop. Can the action be executed only 3 seconds before the run switch?
2. Outdated tasks remain in the task plan.
3. Just like my batch script, the e shortcut in the quick launch bar is gone, leaving only a shortcut on the desktop!
4. The first function I achieved with my batch, the others are equivalent to my batch and have the same problem!

Hope to be corrected!

Summary: I still prefer the batch method because I am not familiar with VBS!

[ Last edited by chishingchan on 2008-2-19 at 03:14 PM ]
Floor12 fastslz Posted 2008-02-19 15:16
铂金会员 Posts 2,315 Credits 5,493 From 上海
Wscript.sleep 120000
Subtract 1 minute from 2 minutes for the waiting of at execution, that is, waiting for 1 minute. Maybe it's a bit long, but it's also necessary. (For the first login, with a slightly worse configuration, it might not have logged in to the desktop in 1 minute)

SithTime = FormatDateTime (DateAdd("s",60,Time) ,0)
This is to set the next minute (60 seconds) of the current time
Wscript.sleep 1000 = 1 second
Floor13 chishingchan Posted 2008-02-19 15:22
银牌会员 Posts 538 Credits 1,284
fastslz misunderstood the question in the top post?!
1. Not converted or rewritten to VBS
2. Residual tasks not resolved!
3. e shortcut not resolved!
4. Newly discovered that there is also a deadlock phenomenon, manifested as no response when clicking desktop icons with the mouse, and it is normal only after logging out and logging in through the task manager!
Floor14 chishingchan Posted 2008-02-19 15:26
银牌会员 Posts 538 Credits 1,284
Originally posted by fastslz at 2008-2-19 02:33 PM:

There is no such bug as you mentioned here


The reason you don't have this bug is that you haven't dealt with the remaining outdated tasks. If I comment out "at /delete /yes" in my batch file, there is no (blank desktop) error, but a new problem will occur (remaining outdated tasks)

Let's put aside other things like the shortcut of e and the unresponsive phenomenon!
Floor15 fastslz Posted 2008-02-19 15:30
铂金会员 Posts 2,315 Credits 5,493 From 上海
1. Batch processing to calculate the next minute is inaccurate (even if made very accurate, the code is more complicated), VBS is accurate to the second
2. Residual tasks are okay
3. The e shortcut is also okay
4. No freezes either
5. In short~It depends on the personal system situation
1 2  Next
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023