Forum Discussion
avinashs15
12 years agoOccasional Contributor
Hi,
Im trying to get memory consumed by a process
We are mainly using C# scripit for our project. we were able to get vbscripot of test complete but not with c# script.
This is the method
function Test7(system,login,pwd)
{ var i,colItems,sWMI;
//var asd = Sys["OleObject"]("WbemScripting.SWbemLocator");
sWMI=Sys["OleObject"]("WbemScripting.SWbemLocator")
wmiserv= Sys["OleObject"]("WbemScripting.SWbemLocator")["ConnectServer"](system,"root\\cimv2",login,pwd);//,"", "",0,"")
Sys["OleObject"]("WbemScripting.SWbemLocator")["Security_"]["ImpersonationLevel"] = 3;
var colItems= wmiserv["ExecQuery"]("SELECT * FROM Win32_Process")
Log["Message"](colItems["Count"]);
for (i=1;i<=colItems["Count"];i++)
{
Log["Message"]( colItems["Item"](i)["Name"])
}
}
colItems["Count"] returns proper count (number of process running on the server. However, when i use colItems["Item"](i)["Name"], it gives me general error.
Appritiate the help. We need exuivalent c# script
Im trying to get memory consumed by a process
We are mainly using C# scripit for our project. we were able to get vbscripot of test complete but not with c# script.
This is the method
function Test7(system,login,pwd)
{ var i,colItems,sWMI;
//var asd = Sys["OleObject"]("WbemScripting.SWbemLocator");
sWMI=Sys["OleObject"]("WbemScripting.SWbemLocator")
wmiserv= Sys["OleObject"]("WbemScripting.SWbemLocator")["ConnectServer"](system,"root\\cimv2",login,pwd);//,"", "",0,"")
Sys["OleObject"]("WbemScripting.SWbemLocator")["Security_"]["ImpersonationLevel"] = 3;
var colItems= wmiserv["ExecQuery"]("SELECT * FROM Win32_Process")
Log["Message"](colItems["Count"]);
for (i=1;i<=colItems["Count"];i++)
{
Log["Message"]( colItems["Item"](i)["Name"])
}
}
colItems["Count"] returns proper count (number of process running on the server. However, when i use colItems["Item"](i)["Name"], it gives me general error.
Appritiate the help. We need exuivalent c# script
Related Content
Recent Discussions
- 2 hours agosimonaferrara
- 6 hours agoAli2