FOR Statement

  • Thread starter Thread starter Barney
  • Start date Start date
B

Barney

Why isn't the following working? The DIR command works
interactively. Is there a reserved shell character that
I'm failing to escape?


SET /P ComputerName=Enter the name of the computer that
you want to clean up:^\^>

FOR %%X IN ('"DIR \\%ComputerName%
\C$\WINNT\$NTUninstall* /A:H /B /S"') DO RD /S /Q %%X
 
Barney said:
Why isn't the following working? The DIR command works
interactively. Is there a reserved shell character that
I'm failing to escape?


SET /P ComputerName=Enter the name of the computer that
you want to clean up:^\^>

FOR %%X IN ('"DIR \\%ComputerName%
\C$\WINNT\$NTUninstall* /A:H /B /S"') DO RD /S /Q %%X

set /p which_computer="Enter the name of the computer that you want to clean up: >"
if not defined which_computer set which_computer=%computername%
for /f "tokens=*" %%X in ('dir /AD /B /S "\\%which_computer%\c$\winnt\$NTUninstall*"') do echo rd /s /q "%%X"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top