Showing results for 
Search instead for 
Did you mean: 
Level 7

sbadmcl cleanupmachinegroup script needed

I need a vb script or a bat file that i can loop through a text file containing all my machine groups.

I am trying to run the cleanupmachinegroups command via sbadmcl but the problem is i have about 200 machine groups.  I have all my machine groups listed in a text file i just need a simple bat file or vbs file to loop through that text file so i dont have to set here and run this command 200 times. 

Anyone out there with such a script or bat?

0 Kudos
2 Replies
Level 21

Re: sbadmcl cleanupmachinegroup script needed


for /F %1 in (filename.text) do echo %1

on a command line will process each line of text in a file (and echo it)

to do it in VBScript is a little harder, but gives you more flexibility.

dim oFSO : set oFSO = createobject("scripting.filesystemobject")

dim oFile : set oFile = oFSO.OpenTextFile("test.txt",1)

while not oFile.AtEndOfStream

           WScript.Echo oFile.ReadLine


will read the file line by line,

set oFSO = createobject("scripting.filesystemobject")

data = oFSO.OpenTextFile("test.txt",1).readall

data = Split(data,vbCrLf)

For Each item In data

          WScript.Echo item


will read the whole file, split it by line feeds and output it (probaby faster as there are less reads)

Finally, can't you use "*" as a group name? I know that works with some commands - not sure about the cleanup ones though.

Message was edited by: SafeBoot on 3/20/14 4:52:28 PM EDT
0 Kudos
Level 7

Re: sbadmcl cleanupmachinegroup script needed

Unfortunatley the * wild card doesnt work with this one.  Thanks for the info though.  Ill give them a shot. 

0 Kudos