msdos for loops

  • Cae
  • Expert
  • Expert
  • User avatar
  • Posts: 734

Post 3+ Months Ago

ok, what i am trying to do is write a batch file to wipe user profiles on seqentially numbered computers (ie comp1, comp2, comp3...)

what i want is something like the following(this is written in php, i want it in msdos):
Code: [ Select ]
$startNode = 12;
$endNode = 26;

for($i = $startNode; $i <= $endNode; $i++){
   *random commands here*
}
  1. $startNode = 12;
  2. $endNode = 26;
  3. for($i = $startNode; $i <= $endNode; $i++){
  4.    *random commands here*
  5. }


just a simple for loop, however it needs to be in dos, and needless to say, i have no idea how to do that. help!
  • this213
  • Guru
  • Guru
  • User avatar
  • Posts: 1260
  • Loc: ./

Post 3+ Months Ago

Code: [ Select ]
@echo off
FOR /L %%K IN (12,1,26) DO
  random commands
  1. @echo off
  2. FOR /L %%K IN (12,1,26) DO
  3.   random commands

Where 12 is your starting point, 1 is the number to increment by, and 26 is your stop point.

** I think my age is showing with this one **
hth
$this

*edit*
%%K to access the current number, ie:
Code: [ Select ]
@echo off
FOR /L %%K IN (12,1,26) DO
  %%K commands
  1. @echo off
  2. FOR /L %%K IN (12,1,26) DO
  3.   %%K commands
  • Cae
  • Expert
  • Expert
  • User avatar
  • Posts: 734

Post 3+ Months Ago

thanks...

ive been trying to write the rest of this script for the better part of a day, and i know exactly what i want to do (and how i want to do it in PHP that is)

what i need to do is write a script that will go into a share (of the 'documents and settings' folder) and will selectively delete stuff in it (ie everything except the 'all users', 'administrator', 'local settings', etc)

i have no idea how to do this... the only wa i can think of is using an array, and i do not believe that dos supports that...

any suggestions?
  • this213
  • Guru
  • Guru
  • User avatar
  • Posts: 1260
  • Loc: ./

Post 3+ Months Ago

Are you trying to just arbitrarily remove all of the users from different machines, or are you trying to create a list of users to remove then process based on that list?

Either way - this would be alot easier to code in Perl (especially if you alreay know PHP). Perl can be run from the command line and access any drives you have shared, can use arrays, hashes (associative arrays) and have powerful regexps (which in my opinion are easier to handle than PHP's so called PREGS). If all this is being done from one machine - through shares - this is definitely the way to go. Perl is fairly easy to install and get running on practically any system I can think of - you don't have to have a webserver installed for it to work (as alot of people seem to think)

If you're at a point where you're needing to manage multiple user accounts, perhaps you'd do well to set up a roving profiles server. You can set one up to work with any distribution of Windows (Well, 95, 98, 2K, ME, NT, XP - They can't do 3.x but I doubt you're using that anyway). They're best run on Linux (due to the lower overhead) and Linux can PDC for your domain and whatnot - giving you just one machine to handle all of your profiles and Logons. Windows NT, 2K and XP can also act as PDC's (it's built in) if you're not wanting to take the dive into Linux.

Roving profiles is what I do - doesn't mean you have to though. They allow a user to log in on any system on the domain with his/her credentials and all of their settings will follow them (Mail settings, desktop appearance, even menus if you configure that). The only drawback is that each machine will have to be configured for this, but you can broadcast the policy as a domain security policy and is should update all of the machines on the domain to the new settings (except Windows 95/98 - you have to do those manually - I think)

If this absolutely must be in DOS, you're going to have to set up tests to see if each folder is on in a list of folders you want to keep - which you'll have to create and import (for easy administration) or hard code into the BAT (for much easier coding). If you know the names of all the folders you want to keep - and they're going to be the same on each machine, you'd do better to hard code it. If you're going to want to be able to add "good" user folder that aren't to be deleted (and that change from time to time) you'd do better to import a list.

My DOS is too rusty to remember exactly how to do this, but I can tell you you're going to have to make extensive use of GOTO's and labels. I do most of my shell stuff in Perl these days (even in Windows).
  • Cae
  • Expert
  • Expert
  • User avatar
  • Posts: 734

Post 3+ Months Ago

ok, i just found this one microsquish utility to do exactly what i want: http://www.microsoft.com/downloads/deta ... 0394E98E1E so know i don thave to write this script anymore :) thanks for your help though :)

Post Information

  • Total Posts in this topic: 5 posts
  • Users browsing this forum: No registered users and 58 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.