China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-06-22 05:56
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Share] Batch Program for Hiding Processes and Switching System Users View 2,142 Replies 22
Original Poster Posted 2008-02-19 12:24 ·  中国 广东 东莞 电信
银牌会员
★★★
Credits 1,282
Posts 538
Joined 2002-11-02 00:00
23-year member
UID 129
Gender Male
Status Offline
```
@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 ]
```
Floor 2 Posted 2008-02-19 12:27 ·  中国 广东 东莞 电信
银牌会员
★★★
Credits 1,282
Posts 538
Joined 2002-11-02 00:00
23-year member
UID 129
Gender Male
Status Offline
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 ]
Floor 3 Posted 2008-02-19 12:40 ·  中国 上海 松江区 电信
铂金会员
★★★★
DOS一根葱
Credits 5,493
Posts 2,315
Joined 2006-05-01 10:41
20-year member
UID 54766
Gender Male
From 上海
Status Offline
I don't know what you're up to. What's your intention?
第一高手 第二高手

Floor 4 Posted 2008-02-19 13:00 ·  中国 广东 东莞 电信
银牌会员
★★★
Credits 1,282
Posts 538
Joined 2002-11-02 00:00
23-year member
UID 129
Gender Male
Status Offline
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 ]
Floor 5 Posted 2008-02-19 13:12 ·  中国 上海 松江区 电信
铂金会员
★★★★
DOS一根葱
Credits 5,493
Posts 2,315
Joined 2006-05-01 10:41
20-year member
UID 54766
Gender Male
From 上海
Status Offline
Does the /delete /yes command have permission? This VBS is very simple
第一高手 第二高手

Floor 6 Posted 2008-02-19 13:42 ·  中国 广东 东莞 电信
银牌会员
★★★
Credits 1,282
Posts 538
Joined 2002-11-02 00:00
23-year member
UID 129
Gender Male
Status Offline
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!
Floor 7 Posted 2008-02-19 14:33 ·  中国 上海 松江区 电信
铂金会员
★★★★
DOS一根葱
Credits 5,493
Posts 2,315
Joined 2006-05-01 10:41
20-year member
UID 54766
Gender Male
From 上海
Status Offline
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
第一高手 第二高手

Floor 8 Posted 2008-02-19 14:35 ·  中国 上海 松江区 电信
铂金会员
★★★★
DOS一根葱
Credits 5,493
Posts 2,315
Joined 2006-05-01 10:41
20-year member
UID 54766
Gender Male
From 上海
Status Offline
Wait a minute, I'll write a VBS for you~~~~
第一高手 第二高手

Floor 9 Posted 2008-02-19 14:52 ·  中国 广东 东莞 电信
银牌会员
★★★
Credits 1,282
Posts 538
Joined 2002-11-02 00:00
23-year member
UID 129
Gender Male
Status Offline
Floor 10 Posted 2008-02-19 14:54 ·  中国 上海 松江区 电信
铂金会员
★★★★
DOS一根葱
Credits 5,493
Posts 2,315
Joined 2006-05-01 10:41
20-year member
UID 54766
Gender Male
From 上海
Status Offline
```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
```
第一高手 第二高手

Floor 11 Posted 2008-02-19 15:12 ·  中国 广东 东莞 电信
银牌会员
★★★
Credits 1,282
Posts 538
Joined 2002-11-02 00:00
23-year member
UID 129
Gender Male
Status Offline
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 ]
Floor 12 Posted 2008-02-19 15:16 ·  中国 上海 松江区 电信
铂金会员
★★★★
DOS一根葱
Credits 5,493
Posts 2,315
Joined 2006-05-01 10:41
20-year member
UID 54766
Gender Male
From 上海
Status Offline
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
第一高手 第二高手

Floor 13 Posted 2008-02-19 15:22 ·  中国 广东 东莞 电信
银牌会员
★★★
Credits 1,282
Posts 538
Joined 2002-11-02 00:00
23-year member
UID 129
Gender Male
Status Offline
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!
Floor 14 Posted 2008-02-19 15:26 ·  中国 广东 东莞 电信
银牌会员
★★★
Credits 1,282
Posts 538
Joined 2002-11-02 00:00
23-year member
UID 129
Gender Male
Status Offline
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!
Floor 15 Posted 2008-02-19 15:30 ·  中国 上海 松江区 电信
铂金会员
★★★★
DOS一根葱
Credits 5,493
Posts 2,315
Joined 2006-05-01 10:41
20-year member
UID 54766
Gender Male
From 上海
Status Offline
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
第一高手 第二高手

Forum Jump: