好的,我在這裏有一個錯誤,但不知道在哪裏。我不是以任何方式編碼,這是我從幾個不同的來源彙集而成的。此代碼有效,但它似乎只能以普通用戶身份運行一次,並且只能在提升的權限下運行一次......我只需要它在運行時提升權限即可運行一次。運行VBS腳本提升到遠程計算機的序列號
Set WshShell = WScript.CreateObject("WScript.Shell")
If WScript.Arguments.length = 0 Then
Set ObjShell = CreateObject("Shell.Application")
ObjShell.ShellExecute "wscript.exe", """" & _
WScript.ScriptFullName & """" &_
" RunAsAdministrator", , "runas", 1
End if
On Error Resume Next
Dim System
if Wscript.Arguments.Count >0 then
sSystem=Wscript.Arguments(0)
end if
ComputerName = InputBox("Enter the name of the computer you wish to query")
winmgmt1 = "winmgmts:{impersonationLevel=impersonate}!//"& ComputerName &""
Set SNSet = GetObject(winmgmt1).InstancesOf ("Win32_BIOS")
for each SN in SNSet
MsgBox "The serial number for the specified computer is: " & SN.SerialNumber
next