![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| Guest | recursive directory search I modified the following script from one I found on the web. It searches through an array of computers and lists all of the user folders found within the documents and settings folders on my student computers. Would it be easy to replace the array with something like 047ds* to just search all student computers in my building? Thanks, Jeremy CODE ---------------- '========= arrServers = Array(_ "047ds-c303-21.student.cssd.ab.ca",_ "047ds-c312-20.student.cssd.ab.ca",_ "047ds-cts-05" ) strOutputFile = "StudentComputerProfiles.txt" strStartFolder = "C:\Documents and Settings" Set objFSO = CreateObject("Scripting.FileSystemObject") strResults = "Existing Profiles on student computers" For Each strServer In arrServers strFolder = "\\" & strServer & "\" & Replace(strStartFolder, ":", "$") For Each objSubFolder In objFSO.GetFolder(strFolder).SubFolders strResults = strResults & VbCrLf & strServer & " - " & objSubFolder.Name Next Next Set objOutputFile = objFSO.CreateTextFile(strOutputFile, True) objOutputFile.Write strResults objOutputFile.Close Set objOutputFile = Nothing Set objFSO = Nothing MsgBox "Finished. Please see " & strOutputFile '========= |
My System Specs![]() |
| | #2 (permalink) |
| Guest | Re: recursive directory search "Jeremy" <Jeremy@xxxxxx> wrote in message news:3D3742E7-BDA2-4C63-8518-FD4ED51F1402@xxxxxx Quote: >I modified the following script from one I found on the web. It searches > through an array of computers and lists all of the user folders found > within > the documents and settings folders on my student computers. Would it be > easy > to replace the array with something like 047ds* to just search all student > computers in my building? > Thanks, Jeremy > > CODE > ---------------- > '========= > arrServers = Array(_ > "047ds-c303-21.student.cssd.ab.ca",_ > "047ds-c312-20.student.cssd.ab.ca",_ > "047ds-cts-05" > ) > > strOutputFile = "StudentComputerProfiles.txt" > strStartFolder = "C:\Documents and Settings" > > > Set objFSO = CreateObject("Scripting.FileSystemObject") > > strResults = "Existing Profiles on student computers" > For Each strServer In arrServers > strFolder = "\\" & strServer & "\" & Replace(strStartFolder, ":", > "$") > For Each objSubFolder In objFSO.GetFolder(strFolder).SubFolders > strResults = strResults & VbCrLf & strServer & " - " & > objSubFolder.Name > Next > Next > > Set objOutputFile = objFSO.CreateTextFile(strOutputFile, True) > objOutputFile.Write strResults > objOutputFile.Close > Set objOutputFile = Nothing > Set objFSO = Nothing > > MsgBox "Finished. Please see " & strOutputFile > '========= connected to the network. I found it rather temperamental but perhaps you can use it to generate a list of PCs. |
My System Specs![]() |
| | #3 (permalink) |
| Guest | Re: recursive directory search "Pegasus [MVP]" wrote: Quote: > > "Jeremy" <Jeremy@xxxxxx> wrote in message > news:3D3742E7-BDA2-4C63-8518-FD4ED51F1402@xxxxxx Quote: > >I modified the following script from one I found on the web. It searches > > through an array of computers and lists all of the user folders found > > within > > the documents and settings folders on my student computers. Would it be > > easy > > to replace the array with something like 047ds* to just search all student > > computers in my building? > > Thanks, Jeremy > > > > CODE > > ---------------- > > '========= > > arrServers = Array(_ > > "047ds-c303-21.student.cssd.ab.ca",_ > > "047ds-c312-20.student.cssd.ab.ca",_ > > "047ds-cts-05" > > ) > > > > strOutputFile = "StudentComputerProfiles.txt" > > strStartFolder = "C:\Documents and Settings" > > > > > > Set objFSO = CreateObject("Scripting.FileSystemObject") > > > > strResults = "Existing Profiles on student computers" > > For Each strServer In arrServers > > strFolder = "\\" & strServer & "\" & Replace(strStartFolder, ":", > > "$") > > For Each objSubFolder In objFSO.GetFolder(strFolder).SubFolders > > strResults = strResults & VbCrLf & strServer & " - " & > > objSubFolder.Name > > Next > > Next > > > > Set objOutputFile = objFSO.CreateTextFile(strOutputFile, True) > > objOutputFile.Write strResults > > objOutputFile.Close > > Set objOutputFile = Nothing > > Set objFSO = Nothing > > > > MsgBox "Finished. Please see " & strOutputFile > > '========= > The "net.exe view" command is supposed to give you a list of all computers > connected to the network. I found it rather temperamental but perhaps you > can use it to generate a list of PCs. > computer names to the array, CODE -------------------------------------- Const ForReading = 1 Set objFSO = CreateObject("Scripting.FileSystemObject") Set objTextFile = objFSO.OpenTextFile _ ("c:\computer-names.txt", ForReading) Do Until objTextFile.AtEndOfStream strNextLine = objTextFile.Readline arrServiceList = Split(strNextLine , ",") Loop I'd have to start off with creating the file by invoking a cmd like net view /domain:student>computers.txt and then something to strip out the '\' characters and the rest of the messages echoed back. |
My System Specs![]() |
| | #4 (permalink) |
| Guest | Re: recursive directory search "Jeremy" <Jeremy@xxxxxx> wrote in message news E300E1F-5875-4D17-8C8F-318BA7F99489@xxxxxxQuote: > "Pegasus [MVP]" wrote: > Quote: >> >> "Jeremy" <Jeremy@xxxxxx> wrote in message >> news:3D3742E7-BDA2-4C63-8518-FD4ED51F1402@xxxxxx Quote: >> >I modified the following script from one I found on the web. It >> >searches >> > through an array of computers and lists all of the user folders found >> > within >> > the documents and settings folders on my student computers. Would it >> > be >> > easy >> > to replace the array with something like 047ds* to just search all >> > student >> > computers in my building? >> > Thanks, Jeremy >> > >> > CODE >> > ---------------- >> > '========= >> > arrServers = Array(_ >> > "047ds-c303-21.student.cssd.ab.ca",_ >> > "047ds-c312-20.student.cssd.ab.ca",_ >> > "047ds-cts-05" >> > ) >> > >> > strOutputFile = "StudentComputerProfiles.txt" >> > strStartFolder = "C:\Documents and Settings" >> > >> > >> > Set objFSO = CreateObject("Scripting.FileSystemObject") >> > >> > strResults = "Existing Profiles on student computers" >> > For Each strServer In arrServers >> > strFolder = "\\" & strServer & "\" & Replace(strStartFolder, ":", >> > "$") >> > For Each objSubFolder In objFSO.GetFolder(strFolder).SubFolders >> > strResults = strResults & VbCrLf & strServer & " - " & >> > objSubFolder.Name >> > Next >> > Next >> > >> > Set objOutputFile = objFSO.CreateTextFile(strOutputFile, True) >> > objOutputFile.Write strResults >> > objOutputFile.Close >> > Set objOutputFile = Nothing >> > Set objFSO = Nothing >> > >> > MsgBox "Finished. Please see " & strOutputFile >> > '========= >> The "net.exe view" command is supposed to give you a list of all >> computers >> connected to the network. I found it rather temperamental but perhaps you >> can use it to generate a list of PCs. >> > computer names to the array, > > CODE > -------------------------------------- > Const ForReading = 1 > > Set objFSO = CreateObject("Scripting.FileSystemObject") > Set objTextFile = objFSO.OpenTextFile _ > ("c:\computer-names.txt", ForReading) > > Do Until objTextFile.AtEndOfStream > strNextLine = objTextFile.Readline > arrServiceList = Split(strNextLine , ",") > Loop > > I'd have to start off with creating the file by invoking a cmd like > > net view /domain:student>computers.txt > and then something to strip out the '\' characters and the rest of the > messages echoed back. |
My System Specs![]() |
| | #5 (permalink) |
| Guest | Re: recursive directory search "Pegasus [MVP]" <news@xxxxxx> wrote in message news:OtQIiGG7JHA.3304@xxxxxx Quote: > > "Jeremy" <Jeremy@xxxxxx> wrote in message > news E300E1F-5875-4D17-8C8F-318BA7F99489@xxxxxxQuote: >> "Pegasus [MVP]" wrote: >> Quote: >>> >>> "Jeremy" <Jeremy@xxxxxx> wrote in message >>> news:3D3742E7-BDA2-4C63-8518-FD4ED51F1402@xxxxxx >>> >I modified the following script from one I found on the web. It >>> >searches >>> > through an array of computers and lists all of the user folders found >>> > within >>> > the documents and settings folders on my student computers. Would it >>> > be >>> > easy >>> > to replace the array with something like 047ds* to just search all >>> > student >>> > computers in my building? >>> > Thanks, Jeremy >>> > >>> > CODE >>> > ---------------- >>> > '========= >>> > arrServers = Array(_ >>> > "047ds-c303-21.student.cssd.ab.ca",_ >>> > "047ds-c312-20.student.cssd.ab.ca",_ >>> > "047ds-cts-05" >>> > ) >>> > >>> > strOutputFile = "StudentComputerProfiles.txt" >>> > strStartFolder = "C:\Documents and Settings" >>> > >>> > >>> > Set objFSO = CreateObject("Scripting.FileSystemObject") >>> > >>> > strResults = "Existing Profiles on student computers" >>> > For Each strServer In arrServers >>> > strFolder = "\\" & strServer & "\" & Replace(strStartFolder, ":", >>> > "$") >>> > For Each objSubFolder In objFSO.GetFolder(strFolder).SubFolders >>> > strResults = strResults & VbCrLf & strServer & " - " & >>> > objSubFolder.Name >>> > Next >>> > Next >>> > >>> > Set objOutputFile = objFSO.CreateTextFile(strOutputFile, True) >>> > objOutputFile.Write strResults >>> > objOutputFile.Close >>> > Set objOutputFile = Nothing >>> > Set objFSO = Nothing >>> > >>> > MsgBox "Finished. Please see " & strOutputFile >>> > '========= >>> >>> The "net.exe view" command is supposed to give you a list of all >>> computers >>> connected to the network. I found it rather temperamental but perhaps >>> you >>> can use it to generate a list of PCs. >>> >> computer names to the array, >> >> CODE >> -------------------------------------- >> Const ForReading = 1 >> >> Set objFSO = CreateObject("Scripting.FileSystemObject") >> Set objTextFile = objFSO.OpenTextFile _ >> ("c:\computer-names.txt", ForReading) >> >> Do Until objTextFile.AtEndOfStream >> strNextLine = objTextFile.Readline >> arrServiceList = Split(strNextLine , ",") >> Loop >> >> I'd have to start off with creating the file by invoking a cmd like >> >> net view /domain:student>computers.txt >> and then something to strip out the '\' characters and the rest of the >> messages echoed back. > That's the general idea - good luck! could be because the list comes from the browse master and is not updated instantaneously as computers shutdown or startup. It can be much more efficient than pinging a list of all possible computer names because it retrieves the list from the browse master and does not query the individual machines. Of course, it can miss some that have just come available and will include some that have just shutdown. In my experience, the best time to run a script using this technique is at a time when people are generally all working, and not starting up or shutting down. 9am and 2:30 pm are best for us, but ymmv. Depending on the workstation naming convention, you could do this: net view /domain | find /i "\\047ds" > computers.txt Slightly OT, I usually use this in a strictly batch environment, along these lines: for /f %%C in ('net view ^| find /i "047ds"') do call rocess %%Cpause & goto:eof rocessdir \\%1\c$\documents and settings goto:eof which obviates the need for a temporary file. /Al |
My System Specs![]() |
| | #6 (permalink) |
| Guest | Re: recursive directory search Jeremy, Sorta off topic......but you did mention this ('dead computers')..... Joe Richards has a set of tools at http://www.joeware.net that are simply out of this world. oldcmp is the one that you want to use to clean up your computer account objects in AD. It is an awesome tool. He has others as well (adfind and admod are two.....). I just finished running - over a couple of weeks - oldcmp and in some 45 environments removed some 550 dead computer account objects. This does not include the two clients where there are more than 80 dead accounts each. Stongly suggest that you take a look......you will be very pleased with his tools. And, Al is correct....there is no way that you will *always* get *every* computer....But I know that you know this already. To get back on topic.......I like ping....consider something like this: Set objShell = CreateObject("WScript.Shell") strCommand = "%comspec% /c ping.exe -n 3 -w 1000 " & strComputer & "" Set objExecObject = objShell.Exec(strCommand) HTH, Cary "Jeremy" <Jeremy@xxxxxx> wrote in message news:3D3742E7-BDA2-4C63-8518-FD4ED51F1402@xxxxxx Quote: >I modified the following script from one I found on the web. It searches > through an array of computers and lists all of the user folders found > within > the documents and settings folders on my student computers. Would it be > easy > to replace the array with something like 047ds* to just search all student > computers in my building? > Thanks, Jeremy > > CODE > ---------------- > '========= > arrServers = Array(_ > "047ds-c303-21.student.cssd.ab.ca",_ > "047ds-c312-20.student.cssd.ab.ca",_ > "047ds-cts-05" > ) > > strOutputFile = "StudentComputerProfiles.txt" > strStartFolder = "C:\Documents and Settings" > > > Set objFSO = CreateObject("Scripting.FileSystemObject") > > strResults = "Existing Profiles on student computers" > For Each strServer In arrServers > strFolder = "\\" & strServer & "\" & Replace(strStartFolder, ":", > "$") > For Each objSubFolder In objFSO.GetFolder(strFolder).SubFolders > strResults = strResults & VbCrLf & strServer & " - " & > objSubFolder.Name > Next > Next > > Set objOutputFile = objFSO.CreateTextFile(strOutputFile, True) > objOutputFile.Write strResults > objOutputFile.Close > Set objOutputFile = Nothing > Set objFSO = Nothing > > MsgBox "Finished. Please see " & strOutputFile > '========= |
My System Specs![]() |
| | #7 (permalink) |
| Guest | Re: recursive directory search "Cary Shultz" <cshultz@xxxxxx> wrote in message news:uNmSN6N7JHA.2656@xxxxxx Quote: > Jeremy, > > Sorta off topic......but you did mention this ('dead computers')..... > > Joe Richards has a set of tools at http://www.joeware.net that are simply > out of this world. oldcmp is the one that you want to use to clean up > your computer account objects in AD. It is an awesome tool. He has > others as well (adfind and admod are two.....). > > I just finished running - over a couple of weeks - oldcmp and in some 45 > environments removed some 550 dead computer account objects. This does > not include the two clients where there are more than 80 dead accounts > each. > > Stongly suggest that you take a look......you will be very pleased with > his tools. > > And, Al is correct....there is no way that you will *always* get *every* > computer....But I know that you know this already. Quote: > To get back on topic.......I like ping....consider something like this: > > Set objShell = CreateObject("WScript.Shell") > strCommand = "%comspec% /c ping.exe -n 3 -w 1000 " & strComputer & "" > Set objExecObject = objShell.Exec(strCommand) time consuming, regardless of the proportion that reply. Not only that, but a computer that responds to a ping is still not guaranteed to be available for the duration of whatever process you want to run against it. NET VIEW simulates sort of a snapshot of what was available at some recent time without the time delays of waiting for PINGs. if you run a lengthy process serially against this list, you might be better off with the ping approach. If the process is short, or if it can be multitasked, then NET VIEW is likely the better choice - it certainly is simpler. /Al Quote: > HTH, > > Cary > > "Jeremy" <Jeremy@xxxxxx> wrote in message > news:3D3742E7-BDA2-4C63-8518-FD4ED51F1402@xxxxxx Quote: >>I modified the following script from one I found on the web. It searches >> through an array of computers and lists all of the user folders found >> within >> the documents and settings folders on my student computers. Would it be >> easy >> to replace the array with something like 047ds* to just search all >> student >> computers in my building? >> Thanks, Jeremy >> >> CODE >> ---------------- >> '========= >> arrServers = Array(_ >> "047ds-c303-21.student.cssd.ab.ca",_ >> "047ds-c312-20.student.cssd.ab.ca",_ >> "047ds-cts-05" >> ) >> >> strOutputFile = "StudentComputerProfiles.txt" >> strStartFolder = "C:\Documents and Settings" >> >> >> Set objFSO = CreateObject("Scripting.FileSystemObject") >> >> strResults = "Existing Profiles on student computers" >> For Each strServer In arrServers >> strFolder = "\\" & strServer & "\" & Replace(strStartFolder, ":", >> "$") >> For Each objSubFolder In objFSO.GetFolder(strFolder).SubFolders >> strResults = strResults & VbCrLf & strServer & " - " & >> objSubFolder.Name >> Next >> Next >> >> Set objOutputFile = objFSO.CreateTextFile(strOutputFile, True) >> objOutputFile.Write strResults >> objOutputFile.Close >> Set objOutputFile = Nothing >> Set objFSO = Nothing >> >> MsgBox "Finished. Please see " & strOutputFile >> '========= |
My System Specs![]() |
| | #8 (permalink) |
| Guest | Re: recursive directory search Al, You know what? I like that. I just did it in three production environments and it worked really well. In all cases there was just one machine that was on the list that really isn't. Odd! In all three....one! Anyway, I am going to 'steal' this idea from you. It does look easier. I will play with this and let you know how things turn out. Thanks again, Cary "Al Dunbar" <alandrub@xxxxxx> wrote in message news:%23kN92KT7JHA.728@xxxxxx Quote: > > "Cary Shultz" <cshultz@xxxxxx> wrote in message > news:uNmSN6N7JHA.2656@xxxxxx Quote: >> Jeremy, >> >> Sorta off topic......but you did mention this ('dead computers')..... >> >> Joe Richards has a set of tools at http://www.joeware.net that are simply >> out of this world. oldcmp is the one that you want to use to clean up >> your computer account objects in AD. It is an awesome tool. He has >> others as well (adfind and admod are two.....). >> >> I just finished running - over a couple of weeks - oldcmp and in some 45 >> environments removed some 550 dead computer account objects. This does >> not include the two clients where there are more than 80 dead accounts >> each. >> >> Stongly suggest that you take a look......you will be very pleased with >> his tools. >> >> And, Al is correct....there is no way that you will *always* get *every* >> computer....But I know that you know this already. > I knew that too, but unstated assumptions are often our downfall... > Quote: >> To get back on topic.......I like ping....consider something like this: >> >> Set objShell = CreateObject("WScript.Shell") >> strCommand = "%comspec% /c ping.exe -n 3 -w 1000 " & strComputer & "" >> Set objExecObject = objShell.Exec(strCommand) > The trouble is that pinging a large number of computers in a loop makes it > time consuming, regardless of the proportion that reply. Not only that, > but a computer that responds to a ping is still not guaranteed to be > available for the duration of whatever process you want to run against it. > > NET VIEW simulates sort of a snapshot of what was available at some recent > time without the time delays of waiting for PINGs. if you run a lengthy > process serially against this list, you might be better off with the ping > approach. If the process is short, or if it can be multitasked, then NET > VIEW is likely the better choice - it certainly is simpler. > > /Al > Quote: >> HTH, >> >> Cary >> >> "Jeremy" <Jeremy@xxxxxx> wrote in message >> news:3D3742E7-BDA2-4C63-8518-FD4ED51F1402@xxxxxx Quote: >>>I modified the following script from one I found on the web. It searches >>> through an array of computers and lists all of the user folders found >>> within >>> the documents and settings folders on my student computers. Would it be >>> easy >>> to replace the array with something like 047ds* to just search all >>> student >>> computers in my building? >>> Thanks, Jeremy >>> >>> CODE >>> ---------------- >>> '========= >>> arrServers = Array(_ >>> "047ds-c303-21.student.cssd.ab.ca",_ >>> "047ds-c312-20.student.cssd.ab.ca",_ >>> "047ds-cts-05" >>> ) >>> >>> strOutputFile = "StudentComputerProfiles.txt" >>> strStartFolder = "C:\Documents and Settings" >>> >>> >>> Set objFSO = CreateObject("Scripting.FileSystemObject") >>> >>> strResults = "Existing Profiles on student computers" >>> For Each strServer In arrServers >>> strFolder = "\\" & strServer & "\" & Replace(strStartFolder, ":", >>> "$") >>> For Each objSubFolder In objFSO.GetFolder(strFolder).SubFolders >>> strResults = strResults & VbCrLf & strServer & " - " & >>> objSubFolder.Name >>> Next >>> Next >>> >>> Set objOutputFile = objFSO.CreateTextFile(strOutputFile, True) >>> objOutputFile.Write strResults >>> objOutputFile.Close >>> Set objOutputFile = Nothing >>> Set objFSO = Nothing >>> >>> MsgBox "Finished. Please see " & strOutputFile >>> '========= > > |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Search Directory | Vista General | |||
| Active directory search | PowerShell | |||
| Recursive directory size in O(1) | Vista file management | |||
| Recursive directory size in O(1) | Vista file management | |||
| Recursive text search, displaying filename | PowerShell | |||