Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running Wmi Scripts in ASP NET 1

Status
Not open for further replies.

Hirdyesh

Programmer
May 20, 2005
7
AU
Hi All ,
I am a newbie to WMI scripting , I am aware of the fact that one can run these scripts through Jscript , Vb script, perl and Python to produce output in Html and XMl .Much of it i gathered from info on Microsft 's site and tutorialsand some freely available tools etc. What i am currently trying to acheieve is to gather information /if possible even copy over a copy of all installed drivers from my asp.net client(who is running the application in the browser) to the server side ,I have a script which retrieves all there is too know about these drivers from wmi and it executes on my machine if i run it through a browser , but what i wanna do it to run it through my IIS web server , could some one please point me in the right direction by telling me, the steps involved in order for my code to do so.Plus once i know the physical locations of these drivers what possible mechanism can i use from client side / server side to copy those drivers into a directory on my server.Is it even possible to do so .From what appears from my research is that it is possible to connect to wmi service on a remote machine and to gather info , is it possible to make copies of those files somehow if u know the path say like (H:\WINDOWS\system32\drivers\ALCXWDM.SYS), if so what sort a security restrictions problems i would be facing and how to go by , to overcome them .Thanxs in advance .here is the wmi script .
var wbemFlagReturnImmediately = 0x10;
var wbemFlagForwardOnly = 0x20;

var arrComputers = new Array("BULLET");
for (i = 0; i < arrComputers.length; i++) {
WScript.Echo();
WScript.Echo("==========================================");
WScript.Echo("Computer: " + arrComputers);
WScript.Echo("==========================================");

var objWMIService = GetObject("winmgmts:\\\\" + arrComputers + "\\root\\CIMV2");
var colItems = objWMIService.ExecQuery("SELECT * FROM Win32_SystemDriver", "WQL",
wbemFlagReturnImmediately | wbemFlagForwardOnly);

var enumItems = new Enumerator(colItems);
for (; !enumItems.atEnd(); enumItems.moveNext()) {
var objItem = enumItems.item();

WScript.Echo("AcceptPause: " + objItem.AcceptPause);
WScript.Echo("AcceptStop: " + objItem.AcceptStop);
WScript.Echo("Caption: " + objItem.Caption);
WScript.Echo("CreationClassName: " + objItem.CreationClassName);
WScript.Echo("Description: " + objItem.Description);
WScript.Echo("DesktopInteract: " + objItem.DesktopInteract);
WScript.Echo("DisplayName: " + objItem.DisplayName);
WScript.Echo("ErrorControl: " + objItem.ErrorControl);
WScript.Echo("ExitCode: " + objItem.ExitCode);
WScript.Echo("InstallDate: " + WMIDateStringToDate(objItem.InstallDate));
WScript.Echo("Name: " + objItem.Name);
WScript.Echo("PathName: " + objItem.PathName);
WScript.Echo("ServiceSpecificExitCode: " + objItem.ServiceSpecificExitCode);
WScript.Echo("ServiceType: " + objItem.ServiceType);
WScript.Echo("Started: " + objItem.Started);
WScript.Echo("StartMode: " + objItem.StartMode);
WScript.Echo("StartName: " + objItem.StartName);
WScript.Echo("State: " + objItem.State);
WScript.Echo("Status: " + objItem.Status);
WScript.Echo("SystemCreationClassName: " + objItem.SystemCreationClassName);
WScript.Echo("SystemName: " + objItem.SystemName);
WScript.Echo("TagId: " + objItem.TagId);
}
}

function WMIDateStringToDate(dtmDate)
{
if (dtmDate == null)
{
return "null date";
}
var strDateTime;
if (dtmDate.substr(4, 1) == 0)
{
strDateTime = dtmDate.substr(5, 1) + "/";
}
else
{
strDateTime = dtmDate.substr(4, 2) + "/";
}
if (dtmDate.substr(6, 1) == 0)
{
strDateTime = strDateTime + dtmDate.substr(7, 1) + "/";
}
else
{
strDateTime = strDateTime + dtmDate.substr(6, 2) + "/";
}
strDateTime = strDateTime + dtmDate.substr(0, 4) + " " +
dtmDate.substr(8, 2) + ":" +
dtmDate.substr(10, 2) + ":" +
dtmDate.substr(12, 2);
return(strDateTime);
}
Any Help would be much appreciated ?
Regards
Looney !
 

i don't know much about the subject, but i'm familiar with IIS...what problems are you running into when trying to run through your IIS server?

i'm gonna look up this 'wmi' stuff and see what it's all about.

- g
 
HI Spewn , I am sorry i tooka while to get back , I am currently trying to achieve this by making an active x control instead as this wmi script thing would only run on machines with very low security settings.So i am planning to do this as anactivex control which can get code access and once digitally signed would help get my page a trusted site's status .I have managed to make a mock active x control using links on web i found to create them as usercontrols ina class library and then import them in a asp.net application. the demo tutorial can be found at but this does n't seem to work as my activex object shows up but no textfields are visible on it , i am not sure what's causing this as per the tutorial it should work , but it does n't exactly work as it's meant too .I have put down security for intranet application to low and have even checked Scripts only option from the iis , would u or any programming expert out there happen to know what piece is missing or unconfigured in the puzzle ?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top