
楼主,你好,你的原代码格式有问题,我帮你改了,你试试下边的代码
Set fsoobj = CreateObject("ScriptingFileSystemObject")
DriversInfo = GetDriversInfo
DriversInfo = Replace(DriversInfo, "|", vbCrLf)
sReturn ="硬盘信息:" & vbCrLf & DriversInfo
WscriptEcho sReturn
Function GetDriversInfo()
GetDriversInfo = ""
Set drvObj = fsoobjDrives
For Each D In drvObj
ErrClear
If DDriveLetter <> "A" Then
If DisReady Then
GetDriversInfo = GetDriversInfo & "分区:" & DDriveLetter & vbCrLf
GetDriversInfo = GetDriversInfo & "可用空间:" & cSize(DFreeSpace) & vbCrLf
GetDriversInfo = GetDriversInfo & "总大小:" & cSize( DTotalSize) & vbCrLf
GetDriversInfo = GetDriversInfo & "使用率 :" & (100((DTotalSize-DFreeSpace)/DTotalSize)) &"%" & vbCrLf
GetDriversInfo = GetDriversInfo & "|"
Else
End If
Else
End If
Next
End Function
Function cSize(tSize)
If tSize >= 1073741824 Then
cSize = Int((tSize / 1073741824) 1000) / 1000 & " GB"
ElseIf tSize >= 1048576 Then
cSize = Int((tSize / 1048576) 1000) / 1000 & " MB"
ElseIf tSize >= 1024 Then
cSize = Int((tSize / 1024) 1000) / 1000 & " KB"
Else cSize = tSize & "B"
End If
End Function
一楼不要胡乱回复,那是VBS吗?坑爹呀!!
这是VBS代码:
N = InputBox("请输入进程名称")
Set wmi = GetObject("winmgmts:\\\root\cimv2")
Set ps = wmiExecQuery("select from win32_process where name="&"'"&N&"'")
For Each p In ps
pGetOwner user, domain
MsgBox " notepad的进程的用户名是 " & user '&"," & domain
Next
没必要用vbs,批处理就可搞定。以火狐浏览器firefoxexe为例
@echo off
set im=firefoxexe
for /f “tokens=12" %%i in ('tasklist /fi "status eq NOT RESPONDING"') do (
if "%%i"=="im“ taskkill /f /pid %%j&& start "" "%im%")
以上就是关于用VBS脚本获取硬盘信息全部的内容,包括:用VBS脚本获取硬盘信息、VBS获取系统进程的用户名、如何通过VBS获得系统进程中的运行状态等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)