1.

Solve : Need help with a .cmd file, pretty please!?

Answer»

To save petty details, here is what I am currently using
Keep in MIND the listed code works perfectly on its own when I EDIT the file with a specific directory.

Quote

-Fileremover.cmd-

takeown /F "whatever directory I want" /r /d y
icacls "whatever directory I want" /grant administrators:F /t
call cleanit.cmd

Quote
-cleanit.cmd-

rd /s /q "whatever directory I want"

I am trying to figure out a way to either
A: have the cmd promt me to input the directory to execute the takeown, or
B:use a bat/cmd file to replace a designated directory with a directory specified on the command prompt window inside a CREATED copy or a cmd file.

so for example,
COPY C:\test.txt test2.txt
COPY C:\cleanit.cmd cleanit2.cmd
then have it replace "whatever directory I want" with something I enter into the cmd prompt

afterwards of course have them run then get deleted through some means, which I can do. It is just the input I am having trouble with, I searched high and low as well as tried a few switches and different lines.

I would be happy to even learn some scripting if needed. I just want this to be successful. Thank you for reading and your responses
If this does not make sense I am more than happy to try and clarify. Code: [Select]set /p fpath=Enter in the full path to a directory:
takeown /f "%fpath%" /r /d yThanks Squashman, that actually did the trick, sadly I guess i'll have to input it twice, once for the remover and once for the cleanit.
Either way fantastic job! I greatly appreciate it.Why do you have the CleanIt as a separate batch file? Why not have all the code in one batch file?

And no you would not have to do it twice. You can pass command line arguments to a batch when you start a batch file or call a batch file.

Code: [Select]call cleanit.cmd "%fpath%"Code: [Select]rd /s /q "%~1"
With such simple and basic code I would just combine these two batch files into one.

I was thinking about that actually, I have only starting delving into DOS (Specifically 5.0), and cmd promt so im still in my infancy. I actually figured out I didn't have to re specify it, which did make me happy!
either way it's a decent makeshift virus remover (or at least for what I was trying to get rid of) just wanted to make it more user friendly.

I think I will take your advice though and combine them!So I ended up keeping it in two separate files but thanks to you, this is my end result.

Quote
Fileremover.cmd

set /p fpath=Enter in the full path to a directory:
takeown /f "%fpath%" /r /d y
pause
icacls "%fpath%" /grant administrators:F /t
pause
call cleanit.cmd

Quote
cleanit.cmd

rd /s /q "%fpath%"
pause
@ECHO OFF

:choice
set /P c=If file is still present, would you like to try a GOOGLE search?[Y/N]?
if /I "%c%" EQU "Y" goto :somewhere
if /I "%c%" EQU "N" goto :somewhere_else
goto :choice


:somewhere

echo "Opening up www.google.com"
start www.google.com
echo "Hope you find a way to REMOVE your piece of data!"
pause
exit

:somewhere_else

echo "Huzzah! You win, you awesome person you "
pause
exit

Thanks again Squashman.


Discussion

No Comment Found