|
|
Hi,
I have problem to run vbscript to list all the files of specific extention on remote Cluster Node. I have about 20 cluser servers around the world I want to find all the MP3 files on my servers. I am able to get result on some servers but not on all. I get no error but my code list no file but I see many file on the server.
I am useing this code
strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colFiles = objWMIService.ExecQuery _ ("Select * from CIM_DataFile Where Extension = 'mp3'")
If colFiles.Count = 0 Then Wscript.Quit End If
Set objFSO = CreateObject("Scripting.FileSystemObject") Set objTextFile = objFSO.CreateTextFile("C:\Scripts\mp3.txt")
For Each objFile in colFiles objTextFile.Write(objFile.Drive & objFile.Path & ",") objTextFile.Write(objFile.FileName & "." & objFile.Extension & ",") objTextFile.Write(objFile.FileSize & vbCrLf) Next
objTextFile.Close
If some one have a vb.net code to search files on remote server (may be cluster) then please share with me.
Thanks for any help.
|
|
Hi AKDN,
Try adding these options to the end of your ExecQuery: ,"WQL", _ wbemFlagReturnImmediately + wbemFlagForwardOnly)
...so that you have: Set colFiles = objWMIService.ExecQuery _ ("Select * from CIM_DataFile Where Extension = 'mp3'", _ "WQL", _ wbemFlagReturnImmediately + wbemFlagForwardOnly)
....and you'll also need two constants: Const wbemFlagReturnImmediately = &H10 Const wbemFlagForwardOnly = &H20
N.B. You won't be able to use the ".count" property. You'll have to do your own count incrementer.
Search the web for a description of why the above might work for you.
Regards, Dave.
"AKDN" <AKDN[ at ]discussions.microsoft.com> wrote in message news:8EE9C434-675F-4A68-B8AB-40FA0A592622[ at ]microsoft.com...
[Quoted Text] > Hi, > > I have problem to run vbscript to list all the files of specific extention > on remote Cluster Node. I have about 20 cluser servers around the world I > want to find all the MP3 files on my servers. I am able to get result on > some > servers but not on all. I get no error but my code list no file but I see > many file on the server. > > I am useing this code > > strComputer = "." > Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") > > Set colFiles = objWMIService.ExecQuery _ > ("Select * from CIM_DataFile Where Extension = 'mp3'") > > If colFiles.Count = 0 Then > Wscript.Quit > End If > > Set objFSO = CreateObject("Scripting.FileSystemObject") > Set objTextFile = objFSO.CreateTextFile("C:\Scripts\mp3.txt") > > For Each objFile in colFiles > objTextFile.Write(objFile.Drive & objFile.Path & ",") > objTextFile.Write(objFile.FileName & "." & objFile.Extension & ",") > objTextFile.Write(objFile.FileSize & vbCrLf) > Next > > objTextFile.Close > > > If some one have a vb.net code to search files on remote server (may be > cluster) then please share with me. > > Thanks for any help. > > >
|
|
Hello,
Thanks for your help. But it gave me the same results. I think the volume is so big as it is about 3 TB and I believe that on this 3 TB I have max 500 MP3 files. Do you have any other idea ??
"D.R." wrote:
[Quoted Text] > Hi AKDN, > > Try adding these options to the end of your ExecQuery: > ,"WQL", _ > wbemFlagReturnImmediately + wbemFlagForwardOnly) > > ...so that you have: > Set colFiles = objWMIService.ExecQuery _ > ("Select * from CIM_DataFile Where Extension = 'mp3'", _ > "WQL", _ > wbemFlagReturnImmediately + wbemFlagForwardOnly) > > > ....and you'll also need two constants: > Const wbemFlagReturnImmediately = &H10 > Const wbemFlagForwardOnly = &H20 > > > N.B. You won't be able to use the ".count" property. You'll have to do your > own count incrementer. > > > Search the web for a description of why the above might work for you. > > Regards, > Dave. > > > > "AKDN" <AKDN[ at ]discussions.microsoft.com> wrote in message > news:8EE9C434-675F-4A68-B8AB-40FA0A592622[ at ]microsoft.com... > > Hi, > > > > I have problem to run vbscript to list all the files of specific extention > > on remote Cluster Node. I have about 20 cluser servers around the world I > > want to find all the MP3 files on my servers. I am able to get result on > > some > > servers but not on all. I get no error but my code list no file but I see > > many file on the server. > > > > I am useing this code > > > > strComputer = "." > > Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") > > > > Set colFiles = objWMIService.ExecQuery _ > > ("Select * from CIM_DataFile Where Extension = 'mp3'") > > > > If colFiles.Count = 0 Then > > Wscript.Quit > > End If > > > > Set objFSO = CreateObject("Scripting.FileSystemObject") > > Set objTextFile = objFSO.CreateTextFile("C:\Scripts\mp3.txt") > > > > For Each objFile in colFiles > > objTextFile.Write(objFile.Drive & objFile.Path & ",") > > objTextFile.Write(objFile.FileName & "." & objFile.Extension & ",") > > objTextFile.Write(objFile.FileSize & vbCrLf) > > Next > > > > objTextFile.Close > > > > > > If some one have a vb.net code to search files on remote server (may be > > cluster) then please share with me. > > > > Thanks for any help. > > > > > > > > >
|
|
Hi,
When "*" is used in: "Select * from CIM_DataFile where Extension = 'mp3'"
....it means return all properties of each file. You could reducing the resource load of the query by only requesting the attributes/properties that you really need, e.g.: "Select Drive,Extension,FileName,FileSize,Path from CIM_DataFile where Extension = 'mp3'"
....i.e. selecting only five of the many attributes available, as listed here: http://msdn2.microsoft.com/en-us/library/aa387236.aspx
You could reducing it even more to just FileSize and Path.
Regards, Dave.
"AKDN" <AKDN[ at ]discussions.microsoft.com> wrote in message news:46DFED41-4587-4934-A8CB-F2092C33F0E3[ at ]microsoft.com...
[Quoted Text] > Hello, > > Thanks for your help. But it gave me the same results. I think the volume > is > so big as it is about 3 TB and I believe that on this 3 TB I have max 500 > MP3 > files. Do you have any other idea ?? > > > > "D.R." wrote: > >> Hi AKDN, >> >> Try adding these options to the end of your ExecQuery: >> ,"WQL", _ >> wbemFlagReturnImmediately + wbemFlagForwardOnly) >> >> ...so that you have: >> Set colFiles = objWMIService.ExecQuery _ >> ("Select * from CIM_DataFile Where Extension = 'mp3'", _ >> "WQL", _ >> wbemFlagReturnImmediately + wbemFlagForwardOnly) >> >> >> ....and you'll also need two constants: >> Const wbemFlagReturnImmediately = &H10 >> Const wbemFlagForwardOnly = &H20 >> >> >> N.B. You won't be able to use the ".count" property. You'll have to do >> your >> own count incrementer. >> >> >> Search the web for a description of why the above might work for you. >> >> Regards, >> Dave. >> >> >> >> "AKDN" <AKDN[ at ]discussions.microsoft.com> wrote in message >> news:8EE9C434-675F-4A68-B8AB-40FA0A592622[ at ]microsoft.com... >> > Hi, >> > >> > I have problem to run vbscript to list all the files of specific >> > extention >> > on remote Cluster Node. I have about 20 cluser servers around the world >> > I >> > want to find all the MP3 files on my servers. I am able to get result >> > on >> > some >> > servers but not on all. I get no error but my code list no file but I >> > see >> > many file on the server. >> > >> > I am useing this code >> > >> > strComputer = "." >> > Set objWMIService = GetObject("winmgmts:\\" & strComputer & >> > "\root\cimv2") >> > >> > Set colFiles = objWMIService.ExecQuery _ >> > ("Select * from CIM_DataFile Where Extension = 'mp3'") >> > >> > If colFiles.Count = 0 Then >> > Wscript.Quit >> > End If >> > >> > Set objFSO = CreateObject("Scripting.FileSystemObject") >> > Set objTextFile = objFSO.CreateTextFile("C:\Scripts\mp3.txt") >> > >> > For Each objFile in colFiles >> > objTextFile.Write(objFile.Drive & objFile.Path & ",") >> > objTextFile.Write(objFile.FileName & "." & objFile.Extension & ",") >> > objTextFile.Write(objFile.FileSize & vbCrLf) >> > Next >> > >> > objTextFile.Close >> > >> > >> > If some one have a vb.net code to search files on remote server (may be >> > cluster) then please share with me. >> > >> > Thanks for any help. >> > >> > >> > >> >> >>
|
|
|