标题: [系统相关] [已解决]批处理如何判断多个硬盘分别/各自是MBR分区还是GPT分区? [打印本页]
作者: ygqiang 时间: 2015-1-2 01:04 标题: [已解决]批处理如何判断多个硬盘分别/各自是MBR分区还是GPT分区?
本帖最后由 pcl_test 于 2017-5-2 00:42 编辑
[已解决]如果有2个或者多个硬盘,如何判断每个硬盘是MBR分区还是GTP分区?- @echo off
-
- :IsGPT
- rem 判定是否是GPT磁盘。
- echo list disk >yiwuyun.txt
- for /f "skip=8 tokens=3 delims=B" %%k in ('diskpart /s yiwuyun.txt') do (
- set temp=%%k
- if "!temp:~8,1!"=="*" goto gpt
- )
- set gpt=false
- echo Your disk is MBR disk!
- ping 127.0.0.1 -n 5 >nul 2>nul
- goto nogpt
- :gpt
- set gpt=true
- echo Your disk is GPT disk!
- ping 127.0.0.1 -n 5 >nul 2>nul
- :nogpt
- if exist yiwuyun.txt del yiwuyun.txt || exit /b 1
- rem echo errorlevel is !errorlevel!
- exit /b 0
复制代码
最好能与下面的bat代码,合并下。
bat显示硬盘及分区容量。- @echo off
- del /q c:\diskinfo.* >nul 2>nul
-
- for /f "delims=:" %%i in ('findstr /n "^:DynamicScript$" "%~f0"') do (
- more +%%i "%~f0" > c:\diskinfo.vbs
- )
-
- ping 127.0.0.1 -n 2 >nul 2>nul
-
- echo ——————————————————————————————————————— >nul 2>nul
- start c:\diskinfo.vbs
- ping 127.0.0.1 -n 5 >nul 2>nul
-
- cls
- type c:\diskinfo.txt
-
- ping 127.0.0.1 -n 15 >nul 2>nul & del /q c:\diskinfo.* & exit/b
-
- goto :eof
-
-
-
- echo ——————————————————————————————————————— >nul 2>nul
- :DynamicScript
- Set objWMI = GetObject("winmgmts:\\.\root\cimv2")
- Set colDisks = objWMI.ExecQuery("select * from Win32_DiskDrive where MediaType like 'fixed%'")
-
- For Each objDisk in colDisks
- i = i + 1
- s = s & "硬盘" & i & ":" & vbTab
- s = s & "大小:" & GetSize(objDisk.Size) & vbTab
- s = s & "型号:" & objDisk.Caption & vbCrLf
- strDiskID = Replace(objDisk.DeviceID, "\", "\\")
-
- Set colPartitions = objWMI.ExecQuery _
- ("ASSOCIATORS OF {Win32_DiskDrive.DeviceID=""" & strDiskID & """}" _
- & " where AssocClass=Win32_DiskDriveToDiskPartition")
-
- For Each objPartition in colPartitions
- strPartId = objPartition.DeviceID
-
- Set colLogicalDisks = objWMI.ExecQuery _
- ("ASSOCIATORS OF {Win32_DiskPartition.DeviceID=""" & strPartId & """} where AssocClass=Win32_LogicalDiskToPartition")
-
- For Each objLogicalDisk in colLogicalDisks
- size = objLogicalDisk.Size
- free = objLogicalDisk.Freespace
- used = FormatNumber((size - free) / size * 100, 2, true) & "%"
- s = s & "分区" & objLogicalDisk.DeviceID & vbTab
- s = s & "大小:" & GetSize(size) & vbTab
- s = s & "剩余:" & GetSize(free) & vbTab
- s = s & "使用率:" & used & vbCrLf
- Next
- Next
- s = s & vbCrLf
- Next
-
- Set fso = CreateObject("Scripting.FileSystemObject")
- fso.OpenTextFile("c:\diskinfo.txt", 2, true).Write s
-
- Function GetSize(intSize)
- If intSize/1024/1024 > 1024 Then
- GetSize = FormatNumber(intSize/1024/1024/1024, 2, true) & "GB"
- Else
- Getize = FormatNumber(intSize/1024/1024, 2, true) & "MB"
- End If
- End Function
复制代码
作者: yiwuyun 时间: 2015-1-2 09:29
其实原理是一样的,依次对每个硬盘号进行判定就可以了。如果用VBS,而不是纯批,在WINPE下可能行不通。只有纯批才能保证在WINPE下也能运行。
作者: ygqiang 时间: 2015-1-2 10:14
回复 2# yiwuyun
帮忙合并下1楼的2个代码?谢谢
最好合并成1个bat文件。谢谢
作者: yu2n 时间: 2015-1-2 12:51
第一个脚本不能达到功能吗?
第二个脚本是BAT+VBS混编。
作者: ygqiang 时间: 2015-1-2 16:55
第一个脚本不能达到功能吗?
第二个脚本是BAT+VBS混编。
yu2n 发表于 2015-1-2 12:51
第一个bat 。
只能判断1个硬盘的gpt情况
如果有2个或者多个硬盘,如何判断每个硬盘是MBR还是GTP?
作者: DAIC 时间: 2015-1-2 18:49
试试这样合并:- @echo off
- :IsGPT
- rem 判定是否是GPT磁盘。
- echo list disk >yiwuyun.txt
- for /f "skip=8 tokens=3 delims=B" %%k in ('diskpart /s yiwuyun.txt') do (
- set temp=%%k
- if "!temp:~8,1!"=="*" goto gpt
- )
- set gpt=false
- echo Your disk is MBR disk!
- ping 127.0.0.1 -n 5 >nul 2>nul
- goto nogpt
- :gpt
- set gpt=true
- echo Your disk is GPT disk!
- ping 127.0.0.1 -n 5 >nul 2>nul
- :nogpt
- del /f /q yiwuyun.txt
-
- del /q c:\diskinfo.* >nul 2>nul
-
- for /f "delims=:" %%i in ('findstr /n "^:DynamicScript$" "%~f0"') do (
- more +%%i "%~f0" > c:\diskinfo.vbs
- )
-
- ping 127.0.0.1 -n 2 >nul 2>nul
-
- echo ——————————————————————————————————————— >nul 2>nul
- start c:\diskinfo.vbs
- ping 127.0.0.1 -n 5 >nul 2>nul
-
- cls
- type c:\diskinfo.txt
-
- ping 127.0.0.1 -n 15 >nul 2>nul & del /q c:\diskinfo.* & exit/b
-
- goto :eof
-
-
-
- echo ——————————————————————————————————————— >nul 2>nul
- :DynamicScript
- Set objWMI = GetObject("winmgmts:\\.\root\cimv2")
- Set colDisks = objWMI.ExecQuery("select * from Win32_DiskDrive where MediaType like 'fixed%'")
-
- For Each objDisk in colDisks
- i = i + 1
- s = s & "硬盘" & i & ":" & vbTab
- s = s & "大小:" & GetSize(objDisk.Size) & vbTab
- s = s & "型号:" & objDisk.Caption & vbCrLf
- strDiskID = Replace(objDisk.DeviceID, "\", "\\")
-
- Set colPartitions = objWMI.ExecQuery _
- ("ASSOCIATORS OF {Win32_DiskDrive.DeviceID=""" & strDiskID & """}" _
- & " where AssocClass=Win32_DiskDriveToDiskPartition")
-
- For Each objPartition in colPartitions
- strPartId = objPartition.DeviceID
-
- Set colLogicalDisks = objWMI.ExecQuery _
- ("ASSOCIATORS OF {Win32_DiskPartition.DeviceID=""" & strPartId & """} where AssocClass=Win32_LogicalDiskToPartition")
-
- For Each objLogicalDisk in colLogicalDisks
- size = objLogicalDisk.Size
- free = objLogicalDisk.Freespace
- used = FormatNumber((size - free) / size * 100, 2, true) & "%"
- s = s & "分区" & objLogicalDisk.DeviceID & vbTab
- s = s & "大小:" & GetSize(size) & vbTab
- s = s & "剩余:" & GetSize(free) & vbTab
- s = s & "使用率:" & used & vbCrLf
- Next
- Next
- s = s & vbCrLf
- Next
-
- Set fso = CreateObject("Scripting.FileSystemObject")
- fso.OpenTextFile("c:\diskinfo.txt", 2, true).Write s
-
- Function GetSize(intSize)
- If intSize/1024/1024 > 1024 Then
- GetSize = FormatNumber(intSize/1024/1024/1024, 2, true) & "GB"
- Else
- Getize = FormatNumber(intSize/1024/1024, 2, true) & "MB"
- End If
- End Function
复制代码
作者: ygqiang 时间: 2015-1-2 19:38
试试这样合并:
DAIC 发表于 2015-1-2 18:49
1楼的2个bat代码。
第一个bat 。只能判断1个硬盘的gpt情况
如果有2个或者多个硬盘,如何判断每个硬盘是MBR还是GTP?
作者: ygqiang 时间: 2015-1-2 19:44
试试这样合并:
DAIC 发表于 2015-1-2 18:49
rem 判定是否是GPT磁盘。
这个bat代码,只能判定1个硬盘的情况。
如果有2个或者多个,就不行了。
作者: DAIC 时间: 2015-1-2 20:03
回复 8# ygqiang
先不管多个硬盘的事情,试试合并之后能否正常执行吧。
作者: yu2n 时间: 2015-1-2 20:18
回复 5# ygqiang
检查多个硬盘是不是GPT分区,我这里不方便测试,请自行测试:- @echo off
- for /f "tokens=1,2,* delims= " %%a in ('echo list disk^|diskpart^|find /i "B"') do (
- (echo,%%c|find /i "*" >nul 2>nul) && (
- echo %%a %%b 是GPT分区
- ) || (
- echo %%a %%b 不是GPT分区
- )
- )
- pause
复制代码
作者: ygqiang 时间: 2015-1-2 20:41
回复 ygqiang
先不管多个硬盘的事情,试试合并之后能否正常执行吧。
DAIC 发表于 2015-1-2 20:03
合并之后,能正常执行的。。
作者: ygqiang 时间: 2015-1-2 20:45
回复 ygqiang
检查多个硬盘是不是GPT分区,我这里不方便测试,请自行测试:
yu2n 发表于 2015-1-2 20:18
多谢。这个测试过了。可以。
显示如下:
磁盘0 不是GPT分区 这个是系统盘 东芝ssd 64g
磁盘1 不是GPT分区 这个是数据盘 东芝1T
磁盘2 不是GPT分区 这个是u盘 16G
作者: ygqiang 时间: 2015-1-2 20:47
回复 ygqiang
检查多个硬盘是不是GPT分区,我这里不方便测试,请自行测试:
yu2n 发表于 2015-1-2 20:18
1楼的2个bat代码。
第2个bat 。测试结果如下:
作者: yiwuyun 时间: 2015-1-2 22:12
用查找方法是有缺陷的,因为GPT前面还有一项是DYN,如果DYN是*,就会出错,所以我当时用B作为分隔符,而不是空格。并且我测试过恰好是8个字符。用一个变量,很容易把我写的代码扩展到多个硬盘。每循环一次,变量增1,不跳出循环.我写这个代码是在WINPE下用的,所以全是纯批并且不用其他在WINPE下用不起的工具。
作者: ygqiang 时间: 2015-1-2 22:35
用查找方法是有缺陷的,因为GPT前面还有一项是DYN,如果DYN是*,就会出错,所以我当时用B作为分隔 ...
yiwuyun 发表于 2015-1-2 22:12
多谢。。。能否帮忙合并解决下1楼的2个bat代码?
作者: yu2n 时间: 2015-1-3 07:21
本帖最后由 yu2n 于 2015-1-7 12:23 编辑
Windows XP 的 DiskPart 命令有 BUG ? 我在虚拟机建立了一块硬盘(Disk 1),分区表为 GPT,用PAProCn、DiskGenius 都可以识别为 GPT 分区表,但是 DiskPart 命令识别不出来:- C:\Documents and Settings\Yu2n>ver
-
- Microsoft Windows XP [Version 5.1.2600]
-
- C:\Documents and Settings\Yu2n>diskpart
-
- Microsoft DiskPart version 5.1.3565
-
- Copyright (C) 1999-2003 Microsoft Corporation.
- On computer: PC-02
-
- DISKPART> list disk
-
- Disk ### Status Size Free Dyn Gpt
- -------- ---------- ------- ------- --- ---
- Disk 0 Online 20 GB 0 B
- Disk 1 Online 10 GB 0 B
- Disk 2 Online 500 GB 0 B
-
- DISKPART>
复制代码
因为 DiskPart 不能正常工作,到此为止了……放个VBS代码上来,请自行测试吧:
2015.1.7 更新:感谢 apang 提醒 65 行 GetSize 少了个 S ,现已补上,谢谢。
- RunAsAdmin
- Main
- Sub Main()
- Dim objWMI, colDisks
- Set objWMI = GetObject("winmgmts:\\.\root\cimv2")
- Set colDisks = objWMI.ExecQuery("select * from Win32_DiskDrive where MediaType like 'fixed%'")
- For Each objDisk in colDisks
- s = s & "硬盘" & objDisk.Index & ":" & vbTab
- s = s & "大小:" & GetSize(objDisk.Size) & vbTab
- s = s & "型号:" & objDisk.Caption & vbTab
- s = s & "分区表:" & IsGPT(objDisk.Index) & vbCrLf
- strDiskID = Replace(objDisk.DeviceID, "\", "\\")
- Set colPartitions = objWMI.ExecQuery _
- ("ASSOCIATORS OF {Win32_DiskDrive.DeviceID=""" & strDiskID & """}" _
- & " where AssocClass=Win32_DiskDriveToDiskPartition")
- For Each objPartition in colPartitions
- strPartId = objPartition.DeviceID
- Set colLogicalDisks = objWMI.ExecQuery _
- ("ASSOCIATORS OF {Win32_DiskPartition.DeviceID=""" & strPartId & """} where AssocClass=Win32_LogicalDiskToPartition")
- For Each objLogicalDisk in colLogicalDisks
- size = objLogicalDisk.Size
- free = objLogicalDisk.Freespace
- used = FormatNumber((size - free) / size * 100, 2, true) & "%"
- s = s & "分区" & objLogicalDisk.DeviceID & vbTab
- s = s & "大小:" & GetSize(size) & vbTab
- s = s & "剩余:" & GetSize(free) & vbTab
- s = s & "使用率:" & used & vbCrLf
- Next
- Next
- s = s & vbCrLf
- Next
- WScript.Echo s
- End Sub
-
- ' 格式化
- Function GetSize(intSize)
- If intSize/1024/1024 > 1024 Then
- GetSize = FormatNumber(intSize/1024/1024/1024, 2, true) & "GB"
- Else
- GetSize = FormatNumber(intSize/1024/1024, 2, true) & "MB"
- End If
- End Function
-
- ' 获取指定硬盘的分区表类型(GPT/MBR)
- Function IsGPT(ByVal nDiskIndex)
- IsGPT = "MBR" 'XP 不支持diskpart 识别GPT,默认MBR。感谢 freesoft00 提醒。
- Dim wso, sLogFile, sText
- Set wso = CreateObject("WScript.Shell")
- sLogFile = wso.ExpandenVironmentStrings("%temp%\diskpart.log")
- wso.Run "cmd /c ""chcp 437 & cls & (echo list disk | diskpart | find /i ""Disk " & nDiskIndex & """) >""" & sLogFile & """ "" ", 0, False
- Call TxtFile(sLogFile, 1, -2, sText)
- If Trim(Right(sText,3)) = "*" Then IsGPT = "GPT"
- End Function
-
- ' 对文本指定编码进行读写操作2
- 'nRW: 1只读, 2只写, 8追加 'nCharset: -2(系统), -1(Unicode), 0(ASCII)
- Sub TxtFile(ByVal FileName, ByVal nRW, ByVal nCharset, ByRef sText)
- Dim fso : Set fso = CreateObject("Scripting.filesystemobject")
- If sText <> "" And (nRW = 2 Or nRW = 8) Then
- fso.OpenTextFile(FileName, nRW, True, nCharset).Write sText
- ElseIf fso.FileExists(FileName) And nRW = 1 Then
- If fso.GetFile(FileName).Size > 0 Then _
- sText = fso.OpenTextFile(FileName, nRW, False, nCharset).ReadAll
- End If
- End Sub
-
- ' 以管理员身份运行
- Sub RunAsAdmin()
- Dim objItems, objItem, strVer, nVer
- Set objItems = GetObject("winmgmts:").InstancesOf("Win32_OperatingSystem")
- For Each objItem In objItems
- strVer = objItem.Version
- Next
- nVer = Split(strVer, ".")(0) & Split(strVer, ".")(1)
- If nVer >= 60 Then
- Dim oShell, oArg, strArgs
- Set oShell = CreateObject("Shell.Application")
- If Not WScript.Arguments.Named.Exists("ADMIN") Then
- For Each oArg In WScript.Arguments
- strArgs = strArgs & " """ & oArg & """"
- Next
- strArgs = strArgs & " /ADMIN:1"
- Call oShell.ShellExecute("WScript.exe", """" & WScript.ScriptFullName & """" & strArgs, "", "runas", 1)
- Set oShell = Nothing
- WScript.Quit(0)
- End If
- Set oShell = Nothing
- End If
- End Sub
复制代码
作者: ygqiang 时间: 2015-1-3 09:23
Windows XP 的 DiskPart 命令有 BUG ? 我在虚拟机建立了一块硬盘(Disk 1),分区表为 GPT,用PAProCn、Di ...
yu2n 发表于 2015-1-3 07:21
多谢了。。测试结果可以。不过是弹出窗口,需要用鼠标点击下“确定”按钮。
能否将vbs的结果 输出到txt文件里面
这个我就可以在bat里面显示txt的内容了
start c:\diskinfo.vbs
ping 127.0.0.1 -n 5 >nul 2>nul
cls
type c:\diskinfo.txt
作者: czjt1234 时间: 2015-1-3 10:08
批处理改为
cscript /nologo c:\diskinfo.vbs
pause
作者: ygqiang 时间: 2015-1-3 12:01
本帖最后由 ygqiang 于 2015-1-3 12:19 编辑
批处理改为
cscript /nologo c:\diskinfo.vbs
pause
czjt1234 发表于 2015-1-3 10:08
多谢
能否修改下16楼的vbs代码, 让vbs生成结果放到txt里面
这样bat里面可以直接显示出txt里面的结果
作者: ygqiang 时间: 2015-1-3 12:17
去掉这个弹出窗口,将结果保存到txt文件里面
作者: freesoft00 时间: 2015-1-3 13:29
回复 16# yu2n
xp系统不支持gpt分区,只有2003以上的系统才支持,可以加一个判断,如果当前系统是xp系统就不判断gpt,直接就是mbr格式的。
作者: apang 时间: 2015-1-7 11:42
顶楼代码第65行有一处笔误,Getize 应该为 GetSize
作者: ygqiang 时间: 2015-1-7 15:59
本帖最后由 ygqiang 于 2016-9-8 12:48 编辑
硬盘-格式及分区检测DynamicScript-修正版- @echo off
- echo ——————————————————————————————————————— >nul 2>nul
- echo 判断硬盘是MBR分区还是GTP分区
-
- if exist "c:\diskinfo.*" (del /q "c:\diskinfo.*" >nul 2>nul)
- for /f "delims=:" %%i in ('findstr /n "^:DynamicScript$" "%~f0"') do (
- more +%%i "%~f0" > c:\diskinfo.vbs
- )
- ping 127.0.0.1 -n 2 >nul 2>nul
- cls
- cscript /nologo c:\diskinfo.vbs
- ping 127.0.0.1 -n 2 >nul 2>nul
- CScript /NoLogo c:\diskinfo.vbs>c:\diskinfo.txt
- ping 127.0.0.1 -n 2 >nul 2>nul
- cls
- Type c:\diskinfo.txt
- ping 127.0.0.1 -n 5 >nul 2>nul & if exist "c:\diskinfo.*" (del /q "c:\diskinfo.*" >nul 2>nul)
-
- echo ——————————————————————————————————————— >nul 2>nul
- if exist "c:\diskinfo.*" (del /q "c:\diskinfo.*" >nul 2>nul)
- set "vbs=c:\diskinfo.vbs"
- set "log=c:\diskinfo.log"
- for /f "delims=:" %%i in ('findstr /n "^:DynamicScript$" "%~f0"') do (more +%%i "%~f0" > "%vbs%")
- CScript //NoLogo "%vbs%" > "%log%"
- cls
- type "%log%"
- ping 127.0.0.1 -n 5 >nul 2>nul & if exist "c:\diskinfo.*" (del /q "c:\diskinfo.*" >nul 2>nul) & exit/b
- goto :eof
-
- echo ——————————————————————————————————————— >nul 2>nul
- :DynamicScript
- Main
- Sub Main()
- Dim objWMI, colDisks
- Set objWMI = GetObject("winmgmts:\\.\root\cimv2")
- Set colDisks = objWMI.ExecQuery("select * from Win32_DiskDrive where MediaType like 'fixed%'")
- For Each objDisk in colDisks
- s = s & "硬盘" & objDisk.Index & ":" & vbTab
- s = s & "大小:" & GetSize(objDisk.Size) & vbTab
- s = s & "型号:" & objDisk.Caption & vbTab
- s = s & "分区表:" & IsGPT(objDisk.Index) & vbCrLf
- strDiskID = Replace(objDisk.DeviceID, "\", "\\")
- Set colPartitions = objWMI.ExecQuery _
- ("ASSOCIATORS OF {Win32_DiskDrive.DeviceID=""" & strDiskID & """}" _
- & " where AssocClass=Win32_DiskDriveToDiskPartition")
- For Each objPartition in colPartitions
- strPartId = objPartition.DeviceID
- Set colLogicalDisks = objWMI.ExecQuery _
- ("ASSOCIATORS OF {Win32_DiskPartition.DeviceID=""" & strPartId & """} where AssocClass=Win32_LogicalDiskToPartition")
- For Each objLogicalDisk in colLogicalDisks
- size = objLogicalDisk.Size
- free = objLogicalDisk.Freespace
- used = FormatNumber((size - free) / size * 100, 2, true) & "%"
- s = s & "分区" & objLogicalDisk.DeviceID & vbTab
- s = s & "大小:" & GetSize(size) & vbTab
- s = s & "剩余:" & GetSize(free) & vbTab
- s = s & "使用率:" & used & vbCrLf
- Next
- Next
- s = s & vbCrLf
- Next
- WScript.Echo s
- ' 把显示的内容保存在TXT文件
- ' WScript.Echo s替换为下面的代码
- ' CreateObject("Scripting.filesystemobject").CreateTextFile("结果.txt",2).Write s
- End Sub
- ' 格式化
- Function GetSize(intSize)
- If intSize/1024/1024 > 1024 Then
- GetSize = FormatNumber(intSize/1024/1024/1024, 2, true) & "GB"
- Else
- GetSize = FormatNumber(intSize/1024/1024, 2, true) & "MB"
- End If
- End Function
- ' 获取指定硬盘的分区表类型(GPT/MBR)
- Function IsGPT(ByVal nDiskIndex)
- IsGPT = "MBR"
- Dim wso, sLogFile, sText
- Set wso = CreateObject("WScript.Shell")
- sLogFile = wso.ExpandenVironmentStrings("%temp%\diskpart.log")
- wso.Run "cmd /c ""chcp 437 & cls & (echo list disk | diskpart | find /i ""Disk " & nDiskIndex & """) >""" & sLogFile & """ "" ", 0, False
- Call TxtFile(sLogFile, 1, -2, sText)
- ' If Trim(Right(sText,3)) = "*" Then IsGPT = "GPT"
- If InStrRev(sText, "*")>0 Then IsGPT = "GPT"
- End Function
- ' 对文本指定编码进行读写操作2
- 'nRW: 1只读, 2只写, 8追加 'nCharset: -2(系统), -1(Unicode), 0(ASCII)
- Sub TxtFile(ByVal FileName, ByVal nRW, ByVal nCharset, ByRef sText)
- Dim fso : Set fso = CreateObject("Scripting.filesystemobject")
- If sText <> "" And (nRW = 2 Or nRW = 8) Then
- fso.OpenTextFile(FileName, nRW, True, nCharset).Write sText
- ElseIf fso.FileExists(FileName) And nRW = 1 Then
- If fso.GetFile(FileName).Size > 0 Then _
- sText = fso.OpenTextFile(FileName, nRW, False, nCharset).ReadAll
- End If
- End Sub
- ' 以管理员身份运行
- Sub RunAsAdmin()
- Dim objItems, objItem, strVer, nVer
- Set objItems = GetObject("winmgmts:").InstancesOf("Win32_OperatingSystem")
- For Each objItem In objItems
- strVer = objItem.Version
- Next
- nVer = Split(strVer, ".")(0) & Split(strVer, ".")(1)
- If nVer >= 60 Then
- Dim oShell, oArg, strArgs
- Set oShell = CreateObject("Shell.Application")
- If Not WScript.Arguments.Named.Exists("ADMIN") Then
- For Each oArg In WScript.Arguments
- strArgs = strArgs & " """ & oArg & """"
- Next
- strArgs = strArgs & " /ADMIN:1"
- Call oShell.ShellExecute("WScript.exe", """" & WScript.ScriptFullName & """" & strArgs, "", "runas", 1)
- Set oShell = Nothing
- WScript.Quit(0)
- End If
- Set oShell = Nothing
- End If
- End Sub
复制代码
欢迎光临 批处理之家 (http://bbs.bathome.net/) |
Powered by Discuz! 7.2 |