Link to home
Start Free TrialLog in
Avatar of ti-guy
ti-guy

asked on

batch file not working

Hi,

Anyone see what's wrong here ?

net files | findstr /i "*.Acomba.*"
for /F %%a in ('net files ^|findstr /i "*\Acomba.*")
do net files %%a /close

Thanks,
Avatar of NVIT
NVIT
Flag of United States of America image

Change to...
findstr /i /r ".Acomba."

Open in new window

Avatar of ti-guy
ti-guy

ASKER

On both places ? I still get an error..

net files | findstr /i /r ".Acomba."
for /F %%a in ('net files ^|findstr /i /r ".Acomba.")
do net files %%a /close
What is the error for net files | findstr /i /r ".Acomba."
Avatar of ti-guy

ASKER

The error happens on the second line.


C:\Temp>test.bat

C:\Temp>net files   | findstr /i /r ".Acomba."
The syntax of the command is incorrect.

C:\Temp>for /F %a in ('net files ^|findstr /i "*\Acomba.*")

C:\Temp>

Open in new window

Avatar of ti-guy

ASKER

This is what is in the .bat already. Not sure why it says only % on display...

net files | findstr /i /r ".Acomba."
for /F %%a in ('net files ^|findstr /i /r ".Acomba.")
do net files %%a /close

Open in new window

Add closing single quote at end, right before parenthesis, i.e.
for /F %%a in ('net files ^|findstr /i /r ".Acomba.")
becomes
for /F %%a in ('net files ^|findstr /i /r ".Acomba."')
Avatar of ti-guy

ASKER

I still get that same error

C:\Temp>test.bat

C:\Temp>net files   | findstr /i /r ".Acomba."
The syntax of the command is incorrect.

C:\Temp>for /F %a in ('net files ^|findstr /i /r ".Acomba."')

Open in new window


And thanks a lot for your time
Run net files by itself. What does it return?

net files
net files | findstr /i /r ".Acomba."
for /F %%a in ('net files ^|findstr /i /r ".Acomba." ) do net files %%a /close

Open in new window

Avatar of ti-guy

ASKER

C:\Temp>test2.bat

C:\Temp>net files
There are no entries in the list.


C:\Temp>net files   | findstr /i /r ".Acomba."

C:\Temp>for /F %a in ('net files |findstr /i /r ".Acomba.") do net files %a /clo
se
The system cannot find the file 'net files |findstr /i /r ".Acomba.".

C:\Temp>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of NVIT
NVIT
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ti-guy

ASKER

It works, thanks a lot !
Glad to help. Have a good one.