Link to home
Start Free TrialLog in
Avatar of bbimis
bbimis

asked on

help converting bat to vbs or autoit

@echo off
rem Enter into top level folder, process it and go back to original folder
pushd x
call :processFolder
popd
goto :EOF

:processFolder
rem For each folder in this level
for /D   %%a in (*) do (
   rem Enter into it, process it and go back to original
   cd %%a
   call :processFolder
   cd ..
   rem If is the target folder, delete it
   if /I "%%a" == "downloads" (
      del  /Q "%%a"\*.* 
   )
)
exit /B

Open in new window


I need to convert this to a vbs or exe so I can run it in the background with scheduled task. AS of current, I can make it run but it shows the command window (black screen) and disrupts the users workflow.  I can not figure out how to hide it as there isn't an option.

Thanks!
Avatar of Steve Knight
Steve Knight
Flag of United Kingdom of Great Britain and Northern Ireland image

Quick look but are you just trying to delete the contents of any folders called download?
Avatar of bbimis
bbimis

ASKER

trying to delete the contents of the download folder but since there are several profiles on the computer the download directory is not always in the same spot could be like like
manager\downloads
manager.mydomain\downloads and so on

but yes any folder within the root path that is named downloads i want wiped.
Avatar of bbimis

ASKER

what my ultimate goal is to program a script/task that will purge the files that Outlook Web app downloads. This will prevent other users from viewing download history and seeing files other privilege users have opened.  I know this can be done with firefox settings  but i would prefer a script to do it so it doesn't get turned off/on..
ASKER CERTIFIED SOLUTION
Avatar of Steve Knight
Steve Knight
Flag of United Kingdom of Great Britain and Northern Ireland 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 bbimis

ASKER

That will work thanks. I was originally taking and pushing it into memory and then running it trying to speed it up. but your method is way faster.  Thanks for the help.  AS for the task, they are in some cases still running xp. Anyway thanks again!
Avatar of bbimis

ASKER

one thing I notice in the script at times though
the directory name "whatever path it may be" is too long
OK.  You could try converting to short names (old 8.3 format) to see if that will get around the length issue - does it do it if you leave ECHO In so in the dir/for part, or when it does the delete, which below will be shorter path.

for /f "tokens=*" %%A in ('dir /b /s /ad "%userprofile%\..\downloads"') do ECHO del /Q "%%~sA\*.*"

Steve
Avatar of bbimis

ASKER

The method you posted in terms of short names worked. it was at the delete that i was having the issue.
Thanks!
glad to hear.
Steve