windows - Issue with a batch file I created. It adds a user correctly but won't remove -


i have 40 .txt files named after 40 of users computer , each .txt file contains users ad account. following bat script works great @ injecting ad account administrator group.

mkdir "c:\newtemp\a_accounts" xcopy "\\servername\folder\a_accounts\%computername%.txt" "c:\newtemp\a_accounts" /f "usebackq" %%x in ("c:\newtest\a_accounts\delete\%computername%.txt") (net localgroup administrators %%x /add) 

however, if make new bat file , reverse switch /add /delete doesn't work on new script. have use script above able delete other users local admin group.

mkdir "c:\newtemp\delete_user_admin" xcopy "\\servername\folder\delete_user_admin\%computername%.txt" "c:\newtemp\delete_user_admin" /f "usebackq" %%g in ("c:\newtemp\delete_user_admin\%computername%.txt") (net localgroup administrators %%g /delete) 

when /f runs doesn't (no errors neither. shows line). has me stunned why behaving way. tried changing variable x letter nothing different. clue why happening?

okay looks variable not picking user name in file. replaced second %%g ad username , ran script , deleted account local admin. gotta figure out why /f not working. looking @ website using correct lines.

7/17/2016

yeah stomp why isn't working. ran both lines in .bat , following happens.

this works fine.

for /f "usebackq" %%x in ("c:\newtemp\a_accounts\%computername%.txt") (net localgroup administrators %%x /add) 

however, if change folder breaks (no errors nothing runs line produces nothing.

for /f "usebackq" %%x in ("c:\newtemp\a_accounts2\%computername%.txt") (net localgroup administrators %%x /delete) 

if go .bat file , edit second line point first folder "a_accounts" , flip /add /delete line works fine!!! makes no sense what's ever. have lost hope of being able understand why isn't working should unless has answer.

you copy c:\newtemp\delete_user_admin\%computername% yet read "c:\newtemp\delete_user_admin\%computername%.txt"

these not same.


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -