I have never been a programmer except for some HTML, ages ago. Now I’d like to ask how you guys make those scripts - .bat or something else? - that removes stuff on the system. There are quite a few system files I remove manually after every reinstalltion of Windows XP, it would be nice to run a file that automatically removes all those files (which I’ve put on a nice list in a .txt file).
For the lines that contain RD (Remove Directory), you can prefix those lines with "echo y| "
(N.B. the " | " is the PIPE symbol, not a lower case “L”)
This prefix “pipes” “Y” for YES to automatically answer the request to remove the directory.
At the end of each line that contains a “del” command, you can suffix “>nul:”. This redirects screen output to the nul: device, as opposed to the default output of con:. This keep your screen output clean.
OK thanks. Then I’m lucky to say that the files I wanted to delete through the batch file are actually files related to services. So this will be a nice remove-services-and-related-files batch file. :-TU
Thank you LA for starting this thread I did not realize that running a batch file had the same effect as running from a DOS prompt without starting Windows I should have really :-[
Prior to XP you could do this.
I think Panic’s ROFL was because the “nul” in his post is not a real device or driver, but just an alias, meaning, “instead of outputting to the default output device, con (screen), output to nul (that is output to nothing, don’t give output)”. I’d bet the null.sys file is unrelated to this, and it’s “nul” not “null”. Not sure, LOL. Another example, if instead of “> nul” you added “> prn”, the output would be sent to the printer–at least in the old DOS days.
You can wirte in a .BAT or .CMD file whatever you can write in the command line interface (cmd.exe), one command in each line. (If you don’t want the commands to be shown as they’re run, put a “[ at ]” in front of those you don’t want shown, or “[ at ]echo off” as the first command if you want none shown. This echo is a separate thing from the output.
By the way you don’t need to change the active folder everytime you want to delete files, for example instead of
you can enter
(I wouldn’t recommend running this though, LOL.) The quotation marks are really necessary only if the pathname includes spaces. And I think that the DEL command can delete folders, empty or not, in WinXP, it’s true that in DOS it didn’t so you needed RD and it was a pain so they made DELTREE, but now DEL will detele anything I think.
And it’s better to name the script with a .CMD extension instead of a .BAT one. The difference is that a .BAT file is taken as a DOS script and run in a 16 bits virtual DOS machine (VDM)–when available: ntvdm.exe in Windows 32 bits, not available in Windows 64 bits. A .CMD file is taken as a Win32/64 file and runs natively. Of course either option works the same most times if it includes simple commands like DEL etc., although ntvdm.exe is processor-intensive. Not sure what happens when you run a .BAT file in a system without builtin VDM (64 bits), I guess it’s just run natively like a .CMD one since there’s no other option… so this would only apply to 32 bits Windows.
Oops, it’s ntvdm.exe, that stands for “NT Virtual DOS Machine”. Just run a DOS program or script in Win32 and browse the task manager (and see the cpu usage…). If it’s a Windows 3.x program you’ll also see a wowexec.exe.
No, for example the following would work without quotation marks:
In you example it was necessary however, because there’s a space in “program files”: so you need quotation marks because without them the command line would understand that you want to run a “program” executable in the C:\ root folder, and everything else would be passed as parameter for that executable. In DOS the quotations marks weren’t needed nor used and would have caused an error, since spaces weren’t allowed in filenames; and still many commands and programs accepted switches.