Question : How to remove quotation marks from dsquery results

Hi,

I need to pipe the results of a dsquery to a text file, but I need the results to not have quotation marks around them.

the reason is that Im using dsquery as a batch file to run every 15 minutes and update a text file with a list of all domain users. I will then have another batch file that will parse that text file and set directory permissions based on the list of users in that text file. Im using the "cacls" command line to set the permissions. the problem is that when I use the "for /F %" option in the batch file to parse the text file, it puts the username with the quotation marks in it (since that is the way dsquery generates the results). But cacls does not accept the quotation marks. so the batch file fails.

Is there a way to modify the output format of dsquery to not contain these annoying quotation marks?

thanks.

-omar

Answer : How to remove quotation marks from dsquery results

like I said - use %~i

try this:
for /F %%i in (d:\scripts\domain_Users.txt) do md d:\data\test\%1%%~i

REM ---- sets permissions on all user folders -----

for /F %%i in (d:\scripts\domain_Users.txt) do cacls d:\data\test\%1%%~i /t /c /p VSI\%1%%i:F
for /F %%i in (d:\scripts\domain_Users.txt) do cacls d:\data\test\%1%%~i /t /e /c /g TUCOSI362\Administrators:F
for /F %%i in (d:\scripts\domain_Users.txt) do cacls d:\data\test\%1%%~i /t /e /c /g everyone:R

*********Better still, cut out the dumping to a text file - it's pretty much pointless:**********

for /F %%i in ('dsquery users "OU=internal,OU=accounts,DC=ads,DC=vsi,DC=com" -o samid -limit 0') do md d:\data\test\%1%%~i

REM ---- sets permissions on all user folders -----

for /F %%i in ('dsquery users "OU=internal,OU=accounts,DC=ads,DC=vsi,DC=com" -o samid -limit 0') do cacls d:\data\test\%1%%~i /t /c /p VSI\%1%%i:F
for /F %%i in ('dsquery users "OU=internal,OU=accounts,DC=ads,DC=vsi,DC=com" -o samid -limit 0') do cacls d:\data\test\%1%%~i /t /e /c /g TUCOSI362\Administrators:F
for /F %%i in ('dsquery users "OU=internal,OU=accounts,DC=ads,DC=vsi,DC=com" -o samid -limit 0') do cacls d:\data\test\%1%%~i /t /e /c /g everyone:R


**********Or, if you don't want repeated queries, then keep dumping it to a text file, but I don't understand why you want two batch files - just make the dsquery line the first line in the "second" batch file:

dsquery users "OU=internal,OU=accounts,DC=ads,DC=vsi,DC=com" -o samid -limit 0 >d:\scripts\domain_users.txt

for /F %%i in ('dsquery users "OU=internal,OU=accounts,DC=ads,DC=vsi,DC=com" -o samid -limit 0') do md d:\data\test\%1%%~i

REM ---- sets permissions on all user folders -----

for /F %%i in ('dsquery users "OU=internal,OU=accounts,DC=ads,DC=vsi,DC=com" -o samid -limit 0') do cacls d:\data\test\%1%%~i /t /c /p VSI\%1%%i:F
for /F %%i in ('dsquery users "OU=internal,OU=accounts,DC=ads,DC=vsi,DC=com" -o samid -limit 0') do cacls d:\data\test\%1%%~i /t /e /c /g TUCOSI362\Administrators:F
for /F %%i in ('dsquery users "OU=internal,OU=accounts,DC=ads,DC=vsi,DC=com" -o samid -limit 0') do cacls d:\data\test\%1%%~i /t /e /c /g everyone:R
Random Solutions  
 
programming4us programming4us