Batch job to utilise two data sources?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
mr_Frank
Posts: 10
Joined: 27 Jul 2012 07:48

Batch job to utilise two data sources?

#1 Post by mr_Frank » 05 Aug 2012 15:05

Hello,

I'm working on a script that resets user permissions to their homedrive folder based on an export (of SAM id's) from another batch script.

The batch job consists of two files:

go.bat which executes the job
for /f %%i in (users.txt) do @cmd-series %%i

contents of user.txt is:
username1
username2
username3
.
.

which calls cmd-series.bat
icacls d:\homedrives\%1 /grant %1:(OI)(CI)F /T

In a perfect world this works perfectly but some users have homedrives using names that do not match the SAM id so the script is not always successful.

I do have a second file which contains an export of the homedrive locations (same amount of entries contained) which would marry up with the SAM id file list if there were placed side by side. For example, the contents of these file could be:

fred
bob
alan
.
.


Q. Is there anyway to adapt this batch script so it can take both these exports of user homedrive and SAM data and apply the attribute settings i'm after as part of this job?

Feedback greatly appreciated.


mr_Frank
Posts: 10
Joined: 27 Jul 2012 07:48

Re: Batch job to utilise two data sources?

#3 Post by mr_Frank » 06 Aug 2012 01:40

thanks, that certainly solves part of my problem.

how would/could the script I'm using change to call on both of these items?

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Batch job to utilise two data sources?

#4 Post by foxidrive » 06 Aug 2012 03:52

replace
echo(!file1Line! !file2Line!
with
call :yourbat !file1Line! !file2Line!

and use %1 and %2

mr_Frank
Posts: 10
Joined: 27 Jul 2012 07:48

Re: Batch job to utilise two data sources?

#5 Post by mr_Frank » 07 Aug 2012 02:47

If for example my on input file has the data already combined as per Liviu's resolution, is there any simple way to modify the original batch script so it uses the two parameters.

some lines of the code.bat contain syntax that requires the two parameters whereas some don't.

icacls x:\homedrives\%1 /grant %2:(OI)(CI)F /T

Post Reply