02. juli 2002 - 15:06Der er
8 kommentarer og 1 løsning
Øh...hvad går der galt her?
Hej!
Jeg har et par VBScripts som jeg skal køre (jeg har INGEN forstand på VBScript, AT ALL)...men det fejler :(
Nogen der umiddelbart kan se hvad fejlen er?
Scriptet er her:
'********************************************* '*** assign values to variables strClass = "Win32_PerfRawData_PerfOS_Memory" strNamespace = "root/cimv2" strProperty = "PagesPersec" intInterval = WScript.Arguments(0) 'interval (in seconds) strComputer = WScript.Arguments(1) 'target computer name
'********************************************* '*** connect to WMI using moniker and retrieve collection of '*** all instances of class specified as the script argument Set colInstances = GetObject("winmgmts:{impersonationLevel=impersonate}//" & _ strComputer & "/" & strNameSpace).InstancesOf(strClass)
'********************************************* '*** capture the initial value of the Counter you want to monitor For Each objInstance In colInstances intN0 = objInstance.Properties_.Item(strProperty) WScript.Echo intN0 Next
'********************************************* '*** destroy the objects and collections you created Set objInstance = Nothing Set colInstances = Nothing
'********************************************* '*** in the infinite loop, capture the Counter value at '*** the end of the interval While True
'********************************************* '*** go to sleep for intInverval seconds WScript.Sleep(intInterval * 1000)
'********************************************* '*** connect to WMI using moniker and retrieve collection of '*** all instances of class specified as the script argument Set colInstances = GetObject("winmgmts:{impersonationLevel=impersonate}//" & _ strComputer & "/" & strNameSpace).InstancesOf(strClass)
'********************************************* '*** capture the final value of the Counter you want to monitor For Each objInstance In colInstances intN1 = objInstance.Properties_.Item(strProperty) WScript.Echo intN1 Next
'********************************************* '*** display the result WScript.Echo strProperty & Chr(9) & (intN1 - intN0)/(intInterval)
'********************************************* '*** get ready for the next loop Set objInstance = Nothing Set colInstances = Nothing intN0 = intN1 Wend
----
Og fejlen den siger er:
C:\wmi>cscript //nologo GetCounter.vbs 5 SERVER C:\wmi\GetCounter.vbs(19, 36) Der opstod en Microsoft VBScript-kompileringsfejl: Slut på sætning var ventet
'********************************************* '*** assign values to variables strClass = "Win32_PerfRawData_PerfOS_Memory" strNamespace = "root/cimv2" strProperty = "PagesPersec" intInterval = WScript.Arguments(0) 'interval (in seconds) strComputer = WScript.Arguments(1) 'target computer name
'********************************************* '*** connect to WMI using moniker and retrieve collection of '*** all instances of class specified as the script argument Set colInstances = GetObject("winmgmts:{impersonationLevel=impersonate}//" & _ strComputer & "/" & strNameSpace).InstancesOf(strClass)
'********************************************* '*** capture the initial value of the Counter you want to monitor For Each objInstance In colInstances intN0 = objInstance.Properties_.Item(strProperty) WScript.Echo intN0 Next
'********************************************* '*** destroy the objects and collections you created Set objInstance = Nothing Set colInstances = Nothing
'********************************************* '*** in the infinite loop, capture the Counter value at '*** the end of the interval While True
'********************************************* '*** go to sleep for intInverval seconds WScript.Sleep(intInterval * 1000)
'********************************************* '*** connect to WMI using moniker and retrieve collection of '*** all instances of class specified as the script argument Set colInstances = GetObject("winmgmts:{impersonationLevel=impersonate}//" & _ strComputer & "/" & strNameSpace).InstancesOf(strClass)
'********************************************* '*** capture the final value of the Counter you want to monitor For Each objInstance In colInstances intN1 = objInstance.Properties_.Item(strProperty) WScript.Echo intN1 Next
'********************************************* '*** display the result WScript.Echo strProperty & Chr(9) & (intN1 - intN0)/(intInterval)
'********************************************* '*** get ready for the next loop Set objInstance = Nothing Set colInstances = Nothing intN0 = intN1 Wend Next
dk_akj - har du opgivet, eller har du ikke tid? :) det lader til at du er den eneste der har villet kigge på det....så jeg ville sætte pris på at finde ud af om jeg ska prøve andre steder, eller om du på et tidspunkt får tid....
C:\>cscript //nologo GetCounter.vbs 5 SERVER C:\\GetCounter.vbs(18, 5) Der opstod en Microsoft VBScript-kørselsfejl: Objektet understøtter ikke denne egenskab eller metode: 'objInstance.Properties'
Når jeg tænker over det er det egentligt temmeligt logisk at next ikke må stå på samme linie som echo, overså det bare fuldstændigt.
//akj
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.