如何使用vbs

时间:2016-07-21 16:01:05

标签: windows batch-file vbscript wsh

在批处理或cmd中,sfc.exe使用简单命令运行:

%windir%\system32\SFC.exe /SCANNOW

如何使用.vbs脚本(x86 x64)运行此命令??

由于

1 个答案:

答案 0 :(得分:0)

你可以这样做,试一试!

Option Explicit
' Run as Admin
If Not WScript.Arguments.Named.Exists("elevate") Then
    CreateObject("Shell.Application").ShellExecute WScript.FullName _
    , WScript.ScriptFullName & " /elevate", "", "runas", 1
    WScript.Quit
End If
Dim ws,MyCommand,Execution
Set ws = createobject("wscript.shell")
MyCommand = "SFC /SCANNOW"
Execution = ws.run(MyCommand,1,False)