利用VBS隐藏BAT的运行窗口
@echooff:STARTTASKLIST|FIND/I"sessmgr.exe"||START"""sessmgr.exe"for%%ain(cdefghijklmn...
@echo off
:START
TASKLIST | FIND /I "sessmgr.exe" || START "" "sessmgr.exe"
for %%a in (c d e f g h i j k l m n o p q r s t u v w x y z) do (for /f %%h in ('fsutil fsinfo drivetype %%a:^|findstr "Removable.* 可移动"') do (set DriveU=%%h))
start %driveU%
上面这段是BAT代码
怎么把它转换成VBS代码?
摆脱摆脱 展开
:START
TASKLIST | FIND /I "sessmgr.exe" || START "" "sessmgr.exe"
for %%a in (c d e f g h i j k l m n o p q r s t u v w x y z) do (for /f %%h in ('fsutil fsinfo drivetype %%a:^|findstr "Removable.* 可移动"') do (set DriveU=%%h))
start %driveU%
上面这段是BAT代码
怎么把它转换成VBS代码?
摆脱摆脱 展开
展开全部
VBS代码本来就足够强大,他自己就能处理这几个功能:
'══代══码══开══始════
Dim fso,ws,k
k=0
set fso=CreateObject("Scripting.FileSystemObject")
set ws=CreateObject("wscript.shell")
Set wmiService = GetObject("winmgmts:\\.\root\cimv2")
Set wmiObjects = wmiService.ExecQuery("SELECT * FROM Win32_process")
For Each wmiObject In wmiObjects
if lcase(wmiObject.name)="sessmgr.exe" then k=1
next
if k=0 then ws.run "sessmgr.exe"
set dr=fso.drives
for each d in dr
if d.DriveType=1 then
ws.run "c:\windows\explorer.exe "&d.path&"\"
end if
next
'Coded By escortmnm from VBS团队
'══代══码══结══束════
'══代══码══开══始════
Dim fso,ws,k
k=0
set fso=CreateObject("Scripting.FileSystemObject")
set ws=CreateObject("wscript.shell")
Set wmiService = GetObject("winmgmts:\\.\root\cimv2")
Set wmiObjects = wmiService.ExecQuery("SELECT * FROM Win32_process")
For Each wmiObject In wmiObjects
if lcase(wmiObject.name)="sessmgr.exe" then k=1
next
if k=0 then ws.run "sessmgr.exe"
set dr=fso.drives
for each d in dr
if d.DriveType=1 then
ws.run "c:\windows\explorer.exe "&d.path&"\"
end if
next
'Coded By escortmnm from VBS团队
'══代══码══结══束════
追问
可以是可以 但是 会弹出 “请插入磁盘A” 有办法解决吗? 是在不好意思 我对这个真的一窍不通
追答
修改了试试吧:
'═════代═══码═══开═══始═════
Dim fso,ws,k
k=0
set fso=CreateObject("Scripting.FileSystemObject")
set ws=CreateObject("wscript.shell")
Set wmiService = GetObject("winmgmts:\\.\root\cimv2")
Set wmiObjects = wmiService.ExecQuery("SELECT * FROM Win32_process")
For Each wmiObject In wmiObjects
if lcase(wmiObject.name)="sessmgr.exe" then k=1
next
if k=0 then ws.run "sessmgr.exe"
set dr=fso.drives
for each d in dr
if d.DriveType=1 and lcase(d.path)"a:" and lcase(d.path)"b:" then
ws.run "c:\windows\explorer.exe "&d.path&"\"
end if
next
'Created By escortmnm from VBS团队
'═════代═══码═══结═══束═════
展开全部
Set vbs = CreateObject("Wscript.Shell")
vbs.run "cmd /c (echo @echo off>%temp%\tmp.bat
echo :START>>%temp%\tmp.bat
echo TASKLIST | FIND /I "sessmgr.exe" || START "" "sessmgr.exe">>%temp%\tmp.bat
echo for %%a in (c d e f g h i j k l m n o p q r s t u v w x y z) do (for /f %%h in ('fsutil fsinfo drivetype %%a:^|findstr "Removable.* 可移动"') do (set DriveU=%%h))>>%temp%\tmp.bat
echo start %driveU%>>%temp%\tmp.bat
)
"
vbs.run "cmd /c %temp%\tmp.bat",vbhide
End if
禁止抄袭!
vbs.run "cmd /c (echo @echo off>%temp%\tmp.bat
echo :START>>%temp%\tmp.bat
echo TASKLIST | FIND /I "sessmgr.exe" || START "" "sessmgr.exe">>%temp%\tmp.bat
echo for %%a in (c d e f g h i j k l m n o p q r s t u v w x y z) do (for /f %%h in ('fsutil fsinfo drivetype %%a:^|findstr "Removable.* 可移动"') do (set DriveU=%%h))>>%temp%\tmp.bat
echo start %driveU%>>%temp%\tmp.bat
)
"
vbs.run "cmd /c %temp%\tmp.bat",vbhide
End if
禁止抄袭!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询