Maggie's FarmWe are a commune of inquiring, skeptical, politically centrist, capitalist, anglophile, traditionalist New England Yankee humans, humanoids, and animals with many interests beyond and above politics. Each of us has had a high-school education (or GED), but all had ADD so didn't pay attention very well, especially the dogs. Each one of us does "try my best to be just like I am," and none of us enjoys working for others, including for Maggie, from whom we receive neither a nickel nor a dime. Freedom from nags, cranks, government, do-gooders, control-freaks and idiots is all that we ask for. |
Our Recent Essays Behind the Front Page
Categories
QuicksearchLinks
Blog Administration |
Saturday, July 26. 2008Dr. Mercury's Computer Corner: Lesson 16 - DOS Lesson 16: DOS We learned how to professionally back up our system. We learned how to make a really neat custom links page for our browser. We learned all about hardware and software and cool tools and a whole buncha stuff! And, if all that wasn't enough, we then learned about such cutting-edge techniques as streaming video. As budding computer experts, we're ready to go! So why, in Heaven's name, is the wise and kindly Doc Murky bringing up DOS, of all things? What possible use on God's Green Earth could antiquated old DOS have in today's modern hyperdigital world, we plaintively asked. What use, indeed?, he asked back. Want a quick definition? Computer programs control the computer. DOS is how you control the programs. I use DOS all the time, often in conjunction with MacroScheduler, a program that simulates keyboard and mouse input. Before I give you some examples, let me give you a quick overview of what DOS is. DOS stands for "Disk Operating System" and it's what they used before graphical interfaces (Windows and the mouse) came along. For years, computer operators stared at a small black screen with a white prompt: C:\> staring them in the face. Every single thing you did was initiated by your flying little fingers. The way you controlled the computer was by using DOS commands and running programs directly via DOS. Just picture your own computer minus the mouse and Windows and there ya go. The commands, themselves, are fairly straightforward. 'COPY' copies a file, 'RENAME' renames a file, etc. Example City I should note right up front that none of these are particularly important unto themselves; call it more of an accumulative thing. I hate to belittle it, but in a way DOS is kind of a 'pest eliminator' these days. You'll see what I mean in the examples. A "batch file" is a list of DOS commands. I don't often actually type in a DOS window, but I use batch files all the time. Let's take a look at five different scenarios so you can get a feel for what it's capable of. Don't bother trying to understand the actual commands, just get a general feel for what's involved. 1. The Problem: My Verizon Wireless is treated like a modem and needs to be fired up BY HAND(!) after the computer is up, unlike cable and ADSL which fire up along with the computer. Worse, it actually takes three long, laborious steps on my part, psychologically crippling me by making me feel like I'm stuck in the middle of the 18th century. BY HAND? Surely, there must be a better way. The Solution: My BAT file, with a shortcut icon in the 'Startup' folder so it'll run when Windows loads up, says nothing more than this: c:\tools\msched\msched.exe verizon
What's to note here is that it's possible I could have done the first two steps with DOS, but the third step required the click of a mouse in the 'Minimize' box. That's when a program like MacroScheduler springs to the fore. 2. The Problem: I normally run my monitor 1024 x 768. Some of the games I like to play, like Pandora's Box and the Hoyle games, flip the screen down to an 800 x 600 resolution, which causes the 'SquareOne' pop-out menu bar I use to collapse down to two columns. Normally, it's the height of the monitor, popping out from the left side when touched by the pointer, but it folds down into two short columns when the resolution is reduced. So, I have to MANUALLY(!!) grab the edge of the column and drag it up near the top of the screen, which snaps it back into 1-column mode. Having to do such an onerous task after every game session is obviously enough to keep me from wanting to play the game in the first place. And we can't have that! The Solution: Rather than running the normal Pandora's Box entry in the Start Menu, I run a batch file that says this: C: I then changed the icon of the Pandora BAT file to the actual Pandora icon so there's zero difference when running the game — except that it so very nicely fixes my pop-out menu bar after the game is over. The Solution: Rather than firing up Dreamweaver, I run a batch file that says: C: F: 4. As you might know if (1) you grab a lot of pictures off the web with Internet Explorer and (2) have your settings to show you "hidden files and folders", those damn "thumbs.db" files end up all over the place! Dang, those little rascals are pesky! The Solution: When they start to build up, I run a batch file from my Start Menu called 'Thumbs' which says this: ATTRIB -s -h e:\thumbs.db /s DEL e:\thumbs.db /s The Solution: You can, however, make a copy of the 'index.dat' file. So, first you'd clean everything out, then go to every site and do the login routine. Then store the 'good' cookies and the 'index.dat' file to a separate folder. Then, come maintenance time, empty out the cookies folder, reboot, and let DOS copy the good files back while the computer is booting up and the 'index.dat' file isn't "in use" yet. As I noted, none of these come under the heading of "earthshaking", but they demonstrate perfectly how DOS lets you control things, rather than sitting there frustrated because some program's not operating correctly, or leaving a bunch of files scattered around. Combined with MacroScheduler, you can basically have the computer do anything you, yourself, could do. If you've ever wondered whether or not you'd be "replaced by a computer" someday, this is that moment. I Feel Like I'm In A Sword Fight — Or A Department Store Close-Out Slashes everywhere! You'll notice you're seeing both forward slashes and backslashes. There's actually very little crossover. Backslashes signify paths on a PC, always have. If you're directing the command to some file on the system, you use backslashes. To draw a parallel to last week's lesson on streaming video, I said the 'trick' is to always use the full path name to the video files, that way it's 'transportable', either within your own site or being slapped on another site, like in a comments area. Likewise, whether you're using DOS in real-time or writing a batch file, if you're unsure of the path, just write the whole thing starting with the C drive. That way it doesn't matter where 'you' are on the system, it should be able to find the file if it's there and the path is correct. Tweak Time It just wouldn't feel right if we didn't tweak something first. To open a DOS box, you go to Start Menu, Programs, Accessories, 'Command Prompt'. Go find it and with the right mouse button open its 'Properties'. In the 'Start in' box put: C:\ In The Ballpark DIR /? [ENTER] will show you the template for the DIR command. Note 2: Templates are really confusing. I've been deciphering them for decades and still get stuck when taking a new DOS command out for a spin. As I stated above, normally you won't use a DOS window very much, just batch files, but you often have to first try out the command in real-time using DOS, just to make sure the thing actually works, so you have to know the basics of DOS navigation just to get around the system in the first place. File System Overview Your computer system probably has one hard drive in it. The drive is usually divided into "partitions". Your main C Drive is the 'C' partition, and you might have a 'D' drive, or even more. What's displayed in 'My Computer' is what's on your system. After the hard drive partitions come any ROM drives, then virtual devices and portable devices. In DOS, the 'you' typing into the DOS window is located somewhere on the system. If it says "C:\" next to the prompt, then you're on the root of the 'C' drive. If it says "D:\songs>", you'd be on the 'D' drive in the 'songs' folder. Using four commands, you navigate your way around the system until you're in the folder you want. And Away We Go Pop open a DOS box. If you did the tweak above, the prompt should say "C:\", meaning you're on the root of the 'C' drive. If you want to get a visual reference, open 'My Computer', then the 'C' drive, and that's where you are on the drive. Down below, when you 'DIR' the drive (to list out the contents), you'll see listings of the same folders and files you're seeing in the 'C' drive's window. Capitalization throughout this page is just for clarity. DOS doesn't care about letter case. If I were writing a short batch file, I probably wouldn't bother capitalizing anything, but if it was something complicated, I'd probably upper-case the actual DOS commands (like on this page), just to make it more readable in the future when troubleshooting it. These are the main navigation commands:
You can also skip folders with the CD command, like so: Manipulating Files We use the DIR ("Directory") command to see what's in the current folder. Assuming you're on the root of the 'C' drive, type in:
RENAME <old name> <new name> (REN also works) MOVE <file> <new folder> COPY <file> <new file name> COPY <file> <folder name> MKDIR <new folder name> (MD also works) In a word: DOS is forever. You delete something with DOS, it's history. No friendly Recycle Bin with this gang. So be careful. To delete a file: (DEL also works) There are, of course, zillions of DOS commands out there, but the above is the core group. BAT Files BAT files are always edited with Notepad. They have to be 'pure' text. Another perfect candidate for the SendTo feature. The commands you'll usually use in a BAT file will be the above bunch, with the occasional special-purpose command thrown in. Or, just as likely, a better replacement for an existing DOS command. On the subject, if you're going to replace an existing DOS command, you'll have to give the replacment a different name, i.e. 'ATTRIB2' or 'DELETE2'. When the system sweeps the paths, looking for the command you just typed in, it'll find the original command first and ignore your new one in the 'Command' folder. Thus, it needs to be renamed and the new name used in DOS and batch files. Here's a small package of commands I've used in the past. They are: HOLDIT — A 'pause' command, pausing for X number of seconds or until the 'Any' key is pressed ATTRIB2 — Better 'Attrib' command REPSTR — 'Replace String', replaces bits of text inside of files TDEL — Improved Delete command XCOPY — Improved Copy command Reinventing Windows 98 Okay, now we need to make a home for any wayward DOS commands that drift in, and we have to put the folder 'in the paths' so the system will recognize the commands when we type them in a DOS window or use them in a BAT file. Do this:
If you ever heard that WinXP had "dropped support for DOS", that's what they did. They took the 'Command' folder out of the paths and deleted it, leaving the core DOS commands (which are part of one larger file called CMD.EXE) intact. The ability to just toss a new DOS command in the 'Command' folder and have it automatically be available was what they removed, and we just now fixed it. Attributes Every file on the computer has four 'attributes'. To access them, you open the file's Properties and check or uncheck the appropriate box. They are:
As in the "thumbs.db" example up above, if you want to do something to a system file or a hidden file, you'll have to use the Attrib command first to change them back to normal. Then you can delete, move, rename, etc, the file. BAT Shortcut Icons One thing you might want is for the BAT file to not open a visible box while it's doing its thing. Like in the 'thumbs.db' example, I just want it to scan the hard drive in the background while it's doing the dirty deed, not make a big to-do about it. To run the box in the background, as well as change the icon, you need to make and use a shortcut icon. If you're going to run it from the Start Menu, d-r-a-g the BAT file to the appropriate place on the Start Menu and drop it in. This entry is a shortcut icon, so open its Properties and set the 'Run' box to 'Minimized'. If you want to change the icon in the Start Menu, click on 'Change Icon', then 'OK' if the small box pops up, then the 'Browse' button. Browse to the program whose icon you want to steal. If it's not displaying, select 'Programs' from the drop-down menu at the bottom. If you're going to run the BAT file with an icon, then it'll need to be a shortcut icon if you want it to be customized in any way. Building A BAT File I use the term 'building' because a BAT file is usually constructed in separate stages unless it's fairly small. As noted before, the usual procedure is to first perform it step-by-step via DOS, then scribble the steps into the BAT file as they're proven to work. And, rather than testing it on your real files, you'll probably want to use fake folders and files until it's working, then put in the paths to your real folders and files. BAT Troubleshooting DOS isn't "finicky", as some might describe it. It's exacting. One tiny mixtake in the command line and the BAT file is toast. Nor will you get much feedback from the window as to what screwed up. The best troubleshooting trick is to put a "HOLDIT 10" between each BAT entry. That'll at least allow the DOS box to stop long enough to see what's already worked, then it's a matter of figuring out why the next line didn't work. Online DOS It might come as a surprise that you can use BAT files to upload and download files from a web site with ease. The actual DOS command is 'FTP', which, in turn, runs a secondary file with the site name & password and what files to 'put' or 'get'. Here's the DOS file: FTP -s:script.txt open www.yourdomain.com That would upload the first file to the root of the server and download the second file to the folder the batch file was run from. As a small side note, the script file, above, is using FTP language, like 'put', 'get' and 'quit', to quit the process and close the window. 'Quit' doesn't work in DOS, however. The DOS command to quit the process and close the window is 'EXIT'. Lowering A Program's Priority It's not uncommon to be running a program in the background that uses a lot of CPU, like some sort of conversion program, and have the rest of the system feel kind of sluggish. The manual (cough!) way around this is to:
I'm exhausted just typing it out! With DOS, you'd run the program via a BAT file and use the DOS 'START' command, like so: C: Advanced DOS In truth, we've just scratched the surface of DOS here. Advanced DOS can do such things as (1) generate a list of files, (2) take the top entry of the list, (3) interrogate the file to see if it's one type of format or another or perhaps one size or another, (4) do something or not to the file, depending, (5) save the new file or not, depending, (6) scratch the name from the top of the list, and... IF FILE ON LINE 1 It'll keep repeating the process until there are no more files listed, then quit. As these things go, it can be quite smart. While DOS is pretty much a dinosaur these days, except for small gimicky things like what's on this page, it was once King — and deserves honor for the valuable role it played for so many years. And while it seems ironic that after all the hot and cool computer stuff we've done that we'd end up with humble ol' DOS, it's not, really. When you grab that modern wireless mouse and drag that cool icon from one window to another, what's really going on is the modern version of the MOVE command is moving the dang file. Strip away the Windows user interface and computers are still doing the same simplistic routines they've always done. Thanks again to Bird Dog for allowing me to share a little knowledge with a fine group of people.
Comments
Display comments as
(Linear | Threaded)
Cygwin (runs under windows) gives you instead unix commands and shells, which is all I use.
You'll typically live at say /home/rhh and there's a /tmp and so forth. These have windows names C:/cygwin/home/rhh if you need to mix styles of life. The rest of windows like C:/Program Files has Cygwin names like "/cygdrive/c/Program Files" and so forth. So to a motivated unix guy, windows can be made to do anything. I add the day's dog pictures to flickr with a single command and other important things like that, like daily backups at night. The important thing about scripts is that you not only don't have to be there, but that if it doesn't work, you just change it a little and launch it again and come back later. No hours clicking and mousing. Ron - You remind me that one thing I forgot to mention was DOS's ability to run things at a certain time, either through its own clocking abilities or by using something like Scheduled Tasks. Which -- as I think about it -- would make for a good "Computin' Tips' post. I use Scheduled Tasks to remind me about TV shows, dental appointments, etc, by firing up Notepad files.
If I may ask, what do you mean by "the day's dog pictures"? Are you involved with dogs on a professional level? I ask because I'm thinking of becoming a breeder. No, I just take a camera whenever I take a break from work and take the dog outside. The result is thousands of dog pictures.
http://www.flickr.com/photos/rhhardin Though I've trained previous Dobermans informally up through Utility and Tracking. Ron -
I just checked out the pics up to about page 10. I confess, I learned about a brand new concept from one of the sign pictures: The personal watermelon. Who knew? But there was a watermelon with "Doc" written on it, and others with "Karen", "Jim", "Bob", "Yclept8" -- all of the common everyday names were represented! The personal watermelon. Dobies are great, aren't they? The quintessential example of "The best defense is a good offense". They're not an aggressive animal by nature, as people tend to think they are, but when it comes time to defend something -- look out! I'm a Collie guy, myself, but Dobies are probably second or third on my list. Truly a great dog, and thanks for the slideshow. |
In an effort to round out Maggie's Farm and make it truly eclectic, Bird Dog has invited me to add the geek factor to the mix. But, rather than just adding a few geeky articles here and there, I thought it would be fun to actually get serious about the wh
Tracked: Jul 26, 00:17
Programs AutoSizer — This has two great uses. It'll pop open the browser (or any program) in full-screen mode every time it opens, and for small programs that tend to open wherever they want (like Calculator), it will make them open righ
Tracked: Nov 29, 10:03
Here's an index of my Maggie's Computin' Tips. I can't guarantee all of these will work on every Windows operating system, but most should. Programs AutoSizer — This has two great uses. It'll pop open the browser (or any program) in full-s
Tracked: Jul 10, 11:25
Here's an index of my Maggie's Computin' Tips. I can't guarantee all of these will work on every Windows operating system, but most should. Programs AutoSizer — This has two great uses. It'll pop open the browser (or any program) in full-s
Tracked: Jul 10, 11:27
Here's an index of my Maggie's Computin' Tips. I can't guarantee all of these will work on every Windows operating system, but most should. Programs AutoSizer — This has two great uses. It'll pop open the browser (or any program) in full-scr
Tracked: Jul 22, 19:51
Here's an index of my Maggie's Computin' Tips. I can't guarantee all of these will work on every Windows operating system, but most should. Programs AutoSizer — This has two great uses. It'll pop open the browser (or any program) in full-scr
Tracked: Jul 22, 21:41
Here's an index of my Maggie's Computin' Tips. I can't guarantee all of these will work on every Windows operating system, but most should. Programs AutoSizer — This has two great uses. It'll pop open the browser (or any program) in full-s
Tracked: Jul 23, 13:09
Here's an index of my Maggie's Computin' Tips. I can't guarantee all of these will work on every Windows operating system, but most should. Programs AutoSizer — This has two great uses. It'll pop open the browser (or any program) in full-s
Tracked: Aug 28, 08:33
Here's an index of my Maggie's Computin' Tips. I can't guarantee all of these will work on every Windows operating system, but most should. Programs AutoSizer — This has two great uses. It'll pop open the browser (or any program) in full
Tracked: Jan 08, 20:00