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 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 !