Re: searching synchronously or asynchronously
From: David Wang [Msft] (someone_at_online.microsoft.com)
Date: 04/13/04
- Next message: Stivie S.: "RE: Enumerate users in group"
- Previous message: Jeff Giroux: "searching synchronously or asynchronously"
- In reply to: Jeff Giroux: "searching synchronously or asynchronously"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 12 Apr 2004 21:06:32 -0700
Assuming you have a file called computers.txt which has the name of each
computer on a single line.
On the CMD commandline, run:
FOR /F %A IN ( computers.txt ) DO START CSCRIPT script.vbs %A
This will loop through computers.txt, one line at a time, read the name of
the computer stored within it, and call script.vbs with the name of the
computer and immediately return to the loop, which can immediately call
script.vbs on the next computer.
--
//David
IIS
This posting is provided "AS IS" with no warranties, and confers no rights.
//
"Jeff Giroux" <dabungis@msn.com> wrote in message
news:uE$t7sPIEHA.2656@TK2MSFTNGP11.phx.gbl...
Hi,
I have the below script. It's suppose to go through each computer I set to
strComputer. I use the command line to start the script with arguments for
each PC. Example.
1. Open CMD...
2. Run "script.vbs" [computer1] [computer2] so on.
The script goes through one computer at a time finding the modified date of
each profile. If it's old enough it deletes it. Here's my question. How
can I make the script run on all computers at the same time? Right now, it
connects to [computer1] then it searches for all profiles and deletes, then
it goes to [computer2] and does the same thing. This is find for only a
couple computers. But I have a room of 32 PCs that needs this done every
other week.
Is there a way to run the script, connect to all computers in the command
line argument, and work each computer. This way, it would finish all 32 in
the time it takes just one. My computer is just searching the network
sending the commands. The 32 remote computers are the actual ones doing the
deleting.
Script:
CurrentDate = Date
DaysOld = 7
strComputer = "."
NetPath = "c:\documents and settings\networkservice"
AdminPath = "c:\documents and settings\administrator"
LocalPath = "c:\documents and settings\localservice"
AllPath = "c:\documents and settings\all users"
DefUsrPath = "c:\documents and settings\default user"
objComputers = Wscript.Argument
Set oShell = CreateObject("Wscript.Shell")
For Each RemoteCPU in colComputers
strComputer = RemoteCPU
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colSubfolders = objWMIService.ExecQuery _
("Associators of {Win32_Directory.Name='c:\documents and settings'} "
_
& "Where AssocClass = Win32_Subdirectory " _
& "ResultRole = PartComponent")
For Each objFolder in colSubfolders
fName = objFolder.Name
If fName <> NetPath and fName <> LocalPath and _
fName <> AllPath and fName <> DefUsrPath and _
fName <> AdminPath Then
DelFolder objFolder
End If
Next
Next
Sub DelFolder (objFolder)
FolderDate = objFolder.LastModified
ConversionDate = CDate(Mid(FolderDate, 5, 2) & "/" & _
Mid(FolderDate, 7, 2) & "/" & Left(FolderDate, 4))
DayDiff = DateDiff("d", ConversionDate, CurrentDate)
If DayDiff > DaysOld Then
objFolder.Delete
End If
End Sub
- Next message: Stivie S.: "RE: Enumerate users in group"
- Previous message: Jeff Giroux: "searching synchronously or asynchronously"
- In reply to: Jeff Giroux: "searching synchronously or asynchronously"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|