dreamz - 02 Jan. 2004 - 21:48:
console in windows
i'm looking to do more with xp via the command prompt. what can i do with the console and/or run box? i'm getting used to using the run box to load programs and folders, etc. and using the console to do things like ipconfig, but i want to learn more. what else can i do?
the console in xp doesn't seem very useful, though. what kinds of things can you do in the console?
thanks.
02 Jan. 2004 - 22:25
loveisweakness
02 Jan. 2004 - 22:41
dreamz
thanks.
yeah, i suppose i could just do everything via the gui, but the gui is a little slower and less direct than the command line.
02 Jan. 2004 - 23:01
loveisweakness
yeah i used to delete on 98 using the command prompt as deleting from windows would be slow as hell, but i also never really defragmented, as i was lazy
02 Jan. 2004 - 23:19
dreamz
yeah, but not just that, e.g. running chkdsk.
in xp, you have to go into my computer > right click the drive > tools > scan, but in the command prompt, it's just chkdsk.
You can actually create your own lil apps with batch files and have quicker access to progams with well names shortcuts. Have you messed with the %path% variable before?
Btw, I love this stuff, so may be able to teach you lots.
(Edit)
Oh ya, I have LOTS of apps that add, replace, or extend functionality. We can chat about those later though. All freeware too.

05 Jan. 2004 - 02:35
dreamz
i've never written batch files or anything, but i have used them.
i'm thinking about using some consoles like console2, or maybe trying out cygwin and learning linux.
i'd love to be taught.

First thing about batch files:
They are just text files with a list of commands.
That's it. You can either have them do thing you would type over and over (like going to a common folder) or make things closer to full fledged programs (menus and such).
Ya gotta let me know if you know what I mean by path or "search path" or "application search path" so that I can teach you how to make your own stuff. Hint: the windows folder is in your search path.
While we're at it, for fun, here are two commands I want you to type in (one at a time) for fun:
set
path
:and watch what happens. It will give you some information about your system. Some you know; some you don't (some I don't

). Try it out and check back here. We'll take it another step from there.

05 Jan. 2004 - 18:00
plastic
That reminds me of a certain someone who created a batch file that switched .3DC and Eppie schemes simultaniously. So long ago I don't even remember what the little kinks to work out were, but it's still running on my 98 install

.
06 Jan. 2004 - 00:52
dreamz
isn't path just the location of a folder or file?
i entered those two commands into my command prompt. that's a lot of info!
command line is fun! thanks for the help!
06 Jan. 2004 - 22:52
craeonics
set - environment settings, needed by certain apps
path - paths to certain locations, so that you can launch those apps without having to type their full path
08 Jan. 2004 - 00:04
dreamz
thanks for the explanation. path sounds useful.
08 Jan. 2004 - 00:30
methodik
plastic: that batch file sounds incredibly useful. i could really use something like that for an idea i'm working on. you wouldn't happen to have that kicking around, would you?
08 Jan. 2004 - 01:03
plastic
Ask Red (?) - was just playfully reminding him of it, he created it (can send though if he's ok).
09 Jan. 2004 - 06:46
methodik
I gotta make a projects page, list all the half done stuff I've started, pick one and see it through to completion. I get a lot of good ideas off the ground, yet none take flight. It sadens me. I disapoint myself. Well, I'm not giving up. I'll have to see if I can get up a project page with my space at sknbls.
Back on the subject, know what a search path is will make life a lot easier for you. You should have some windows folders for yours. I customized mine to:
set path=C:\windows;C:\windows\command;D:\;D:\path
: (keep in mind that D:\ is my desktop). THis means that is you type in the name of a program, but not the path from the root of the directory, that is will look for the app in those places if it isn't in the current dirrectory. The D:\path folder (yes, that's it's litteral name) serves as a place for me to throw in all the custom programs I want. I can even easily use them in batch files.
I do this for two reasons:
1) it saves time typing (making the run box a lot more powerful too)
2) my programs can be used like commands in LiteStep & batch files
:in ohter words, it just makes things easier.
I'll go into what you can do with this trick next time (unless someone wants to beat me to it).

10 Jan. 2004 - 03:07
char
I love console.
I do ... in console
- editing files (using vim)
- shutdown windows computer
- compiling souce codes
- compressing exe (using upx)
- finding files
- running console commands
But the console in windows is very limited (limited batch commands), limited color, limited font, limited size. Just try Linux virtual console (boot you kernel with vga=721 + bootsplash, then you'll get a 1024x786 console with 64000 colors with a cute look-like transparent background with a bunch command to do with an easy to use shell (bash). Cygwin console is better but it's still limited since it's running in a console-box. I don't think we can do all thing with GUI alone.
Anyone know of a better console for windows ?
Thank you.
10 Jan. 2004 - 04:09
methodik
well, one of my current projects ( okay, slipped onto the back-burner for the past while ) was a beefed up copy of the reactOS console app. i stubled across the source for it, and have managed to compile it.
it works pretty well, and i was in the process of translating to c++ all the basic functionality of my xBar app so as to make those commands and abilities native to a console shell.
however, even in the days when you actually had to do anything important in DOS, the DOS shell always sucked compared to it's *nix counterpart. it's not just the graphical eye-candy of having a tinted transparent shell running without any window decorations, but also the fact that there are hundreds of commands at your disposal in the *nix bash shell.
i've found that in windows, it's painful to use a console. in linux, it's painful not to.
oh, and
Red, i was wondering if you'd share that batch file plastic said you had. pretty please?
10 Jan. 2004 - 05:10
dreamz
well, i'm going to try out econsole or console2 or something, but i'd need to learn more commands first. it's really useful, as all you guys know.

Char: I took a unix class (college level) before and loved it. It had all the things I saw missing from dos and more. Man, it's scripting let me do stuff I would have to code in c or something. I'm so with you on that one.
Meth: That was so quotable...
"
i've found that in windows, it's painful to use a console. in linux, it's painful not to." -Methodic
...I love it. Awesome one man.
Oh! I'll get that project page up and link it here soon. Is your e-mail from here the one you preffer to be used?
Dreamz: Do you need some of the basics like how to get around in folders, see what is in them, and work around long file names? How about moving, copying, and compairing files? I can give you one trick right now, and it's an awesome one: You can get instructions on how to use a command if you type " /?" after it (space forward, slash, question mark). Try it on the two commands I gave you before ("set /?" and "path /?"). You'll see what I mean.
Btw, you guys know you can have some colors with ansi.sys and do a few other tricks too (in 9x at least), right?
10 Jan. 2004 - 07:09
dreamz
i can get around folders and see what's in them. i remember my dos days.
yeah, i know /? and such.
i'm wondering what i could do with the console, though. you guys seem to use it frequently.
here's one question. how can i create a command to launch certain programs? for example, in the command prompt, you can type chkdsk to launch the process, or you can type regedit to bring up regedit.
10 Jan. 2004 - 07:32
methodik
dreamz - the reason why you are able to type in chkdsk or regedit, and have those commands execute something, is that those commands launch programs, programs that are found within the path. like red mentioned earlier, it's all about the path.
to create a command to launch, say, a group of programs all at once, the absolutely easiest thing to do is create a batch file, seeing as it's just a text file with almost no syntax needed.
i used to love batch files. i once created a menu system for the main library computer back in my school that totally kicked. ( of course, this was on a 286. ) i still remember how wonderful that all seemed.
Red - yeppers, that's the email
10 Jan. 2004 - 07:46
dreamz
yeah, so how would i go about doing that?
let's say i wanted to launch firebird from the command prompt. can i make it so i just type "fb" or something to launch it? how do i do this?
Dreamz: Ah, yes. This is why I showed you the path command. Any folder in that variable (the search path) can be used to do what you mentioned. They basically let skip writing out the full path. Here is what the computer does afer you type in the program name and press enter:
1) it looks for the file with an executable extension, so you don't have to type .exe, .com, or .bat (.lnk too I think)
2) it checks the file is in one of the folders in the path (I think int he order they appear)
3) If it's there, it runs the program as if you typed in the full path
So here is what you would do:
1) open up notepad
2) paste in the full path to firebird in quotes
3) Save it as "fb.bat" rather than "fb.txt" in the windows folder*
If you really want to get a little fancy, you can add " %1" (space - percent - numeral one) to the end. That will let you type in an address after the fb to open websites directly.
*someone correct me on that. I don't know what xp uses for it's path and main folder and crap. I don't use it.
I don't do exacly this, but I do something similar: I just use a shortcut named "k.lnk" (for k-meleon) and put that in my custom path folder. It won't launch from the console window unless you type in "start " first, but it does run nicely from the run box. It's a lot easier to create, and you don't have to add the " %1" or anything fance. No typing other that the name really. In the end, I press "Win+R" for the run box, "k" for the command, and "Enter" to run the command.
This is where the custom folder that I added to the path comes in handy. It lets you have a place dedicated to these little shortcuts so they are easy to manage, edit, or delete. Makes life easier. You'll end up having plenty of these before you know it.
Let me know how it goes.

11 Jan. 2004 - 04:24
dreamz
hey, that's really neat!! i can launch it from the command line.
and yes, the folder is windows, but actually, i can put the batch file anywhere and it'll still work.
what other cool tricks are there? i'm really starting to like this!

How about a binary file compairison to double check if files copied 100% accurately?
fc /b file1 file2
Wild cards can be used to check somplete contents of a folder:
fc /b .\*.* e:\*.*
That checks the current directory (which dos knows as a period) with the e drive (a cd rom in most cases). I call this one "check.bat" and use it to double check my critical back-ups. I just go to the folder I burned (copied, whatever) and type "check" into the command prompt. If anything is different at all, I know something has changed.
On a similar note, you can turn verify on so that when ever a file is moved in dos it is checked before the original is deleted. Much safer than the windows which performs no such check (it just blindly copies and trusts the the diskes and os are reliable). The copy command in dos as an argument /parametet (you know what that means, right?) to do the same thing. It's a feature that should have made it's way into the file manager, but never did.
Try those out, and I'll give you another lesson.
You a're learning much, grass-hopper.

11 Jan. 2004 - 13:59
craeonics
Ergo:
copy /v <source> <destination>
xcopy /v <source> <destination>
Oh and don't forget:
move <source> <destination>
xcopy is copy on steroids, while move moves files instead of making copies.
Anyhow, the documentation of these DOS commands is horrible, especially on Win9x. On NT systems, it's bigger and better (like, there's a 'help' command, which, if I recall correctly, did not appear in 9x and which gives you an overview of the available commands). So I use a scripting language like Ruby instead of batch files.
Actually, I have the original help command from a DOS 6.22 system.

It's out of date, but better than the built in stuff sometimes. If anyone wants to see it out of curiousity, just let me know.

12 Jan. 2004 - 03:55
char
My favourite apps in console
- vim
- fte (know any editor in console? the existing edit.com is very slow on console. The editor fte is much faster and has most of what programmers need)
- wget, my favourite downloader, (1) you can tell it to go background (2) nice progress display (3) reliable, it will re-tries and resume downloads (4) you can resume partial downloaded files (5) support proxy, https, post data, custom header, website authentication, recursive downloads, and more (5) get it from any cygwin mirror
- doskey, you know alias in linux box, this is the counterpart in windows. Just use
doskey ie=c:\program files\internet explorer\iexplore.exe $*
and you can type ie to launch internet explorer without creating batch file. (note $* = pass any argument given)
- would you try my dos prompt

(used in win2000)
prompt $_user:%username%$S$B$Shost:%computername%$S$B$Stime:$T$H$H$H$S$_$P$G
- upx, great for compressing exes, always felt happy upx-ing files
Thanks.
12 Jan. 2004 - 06:00
dreamz
red, i got it. works well.

thanks, sensei!
but /parametet? what's that?
what's the difference between copy and xcopy? and what's the /v for?
When a program is initially run, it can be sent variables to give it instructions. This is done through the command line by adding things after the program's name. This is a special form of in-put called either a parameter or an argument. Here is what it would look like, and then I'll break it down:
copy /v c:\download\metapad.exe c:\windows\notepad.exe /y
Command: copy
1st Parameter: /v
Function: tells the copy command to check if the file copied is exactly the same as the the original, and (if possible fix it if it isn't.
2nd Parameter: c:\download\metapad.exe
Function: Tells where the file to be copied it located at.
3rd Parameter: c:\windows\notepad.exe
Function: Tells the location of the file and the new file name it will have (so it is renaming the file while copying it).
4th Parameter: /y
Function: As you know, the file notepad.exe already exists in that folder. Normally, the copy command would give you the option to either cancel the command or over write the file. It's a yes or no question, or a [y/n] question ya might say. This parameter automatically will over write the file, thus proceeding with the copy as if a [y] was pressed to confirm the action.
The difference b/t copy and xcopy is that xcopy has a LOT more options in it's parameters that it can take. If you are just doing a basic copy, us the copy command; if you need to do something more fancy, the xcopy command may be able to do it better or may be the only way to do it.
Hmmm.... next lesson....
1. Do you know what "wild cards are"?
2. Do you want to learn some batch file commands?
3. Have you ever used ftp.exe before?
Here is a something to try fore the moment. It's the echo command, and it does a lot of stuff. Try these three out:
echo
echo Is there an echo in here?
echo This will create a text file.>c:\file.txt
:and then get back to me on the questions, and if you understand what a parmeter is now.
12 Jan. 2004 - 14:57
grigri
I'd just like to add to Red's explanation that very often arguments are filenames - and since filenames can contain spaces, you need to quote them. ie:
notepad.exe c:\This Text File.txt
will not work because c:\this is the first parameter - you need to put
notepad.exe "c:\This Text File.txt"
This might seem obvious, but I remember a program a friend of mine had that failed randomly for some files. It didn't, of course, it wrote a batch file and didn't include quotes, so file and folder names with spaces made it fail...
12 Jan. 2004 - 16:14
methodik
hmmm.... just a note to that. my runbox alternative xRun2 can handle those type of situations perfectly. when you type in a path with spaces it automatically determines the correct spaces ( including arguments ) by checking for a successful return code. i was planning to use the same sort of logic in a console.
sorta off topic. sorry.

12 Jan. 2004 - 21:30
fallout
Another good command that you can use is more
more file.txt
will display a file one screen at a time
xcopy /? |more
wil pipe the help output of xcopy to more so it will display one screen at a time.
Cool/

Everyone wants to get in on this.

I just hope we don't overwhelm poor Dreamz.

12 Jan. 2004 - 22:55
dreamz
wow, all these posts!
ok red, i know what parameters are (just didn't know the name). i used them when working with ipconfig.
1. i assume wild cards are the same as in real life--they can take on whatever meaning you want, but i don't know how to use it.
2. sure!
3. nope.
i tried the echo command, and it's neat. i created the text file with that particular text simply by typing in the console. what are the uses for this?
grigri, thanks for pointing that out. i myself made that mistake the first time i tried to create the batches.
meth, it's not offtopic. it's cool.
fallout, i'll keep that in mind.
and i'm not overwhelmed. this beats doing homework!

12 Jan. 2004 - 23:17
craeonics
People are going way too fast.
> is called (at least in my memory) redirecting. It will redirect the output of a command to a file. So for instance, where
dir
...would normally list the files in the current directory,
dir > somefile.txt
...will redirect (read:write) the output of dir to the file somefile.txt.
| is called piping. A pipe redirects the output of one file to another file, where that second file uses it as input. So:
dir |more
...will redirect dir's output to the more command.. more displays whatever it is fed one page (as many lines as fit on your console) at a time.
13 Jan. 2004 - 00:24
grigri
This might be a bit technical for some people, but since you're talking about it I'll give you the internal workings:
Console-based apps have 3 "standard handles" called stdout, stdin and stderr (output, input and error handles).
By default, these map to the console buffer (keyboard input and console text output - stderr is the same as stdout by default).
The >,<, and |redirect these handles to other objects. In particular, > redirects stdout to a file, and I believe (though I've never tried) < redirects stdin to a file. | is what is called an "anonymous pipe".
The funny thing about this is that when programming, you use exactly the same functions for reading/writing to these different objects - the ReadFile() API, for example, takes a handle as its first parameter, and that handle can be a file handle, pipe handle, or standard i/o handle - they all work the same way.
This is why integrating these options into the command-line switches is so effortless
Hope that wasn't too off-topic...
13 Jan. 2004 - 03:39
dreamz
O.o
ok, i sort of understand it. i just tried out some commands and i can see what it does.
I know this looks long, but it really is just a lot of copying and pasting.
That's a little above his head. I only understood it because I've studied it on my own and in class, and some terms were unfamiliar even to me. That's ok though. It will make sense to him as he works with this stuff.
Let me explain what echo is used for. This also marks the begining of teaching you how to code batch files.
In the first command, the status of echo is displayed (someone correct me if I said that wrong). You can change this by typing "
echo off" or "
echo on" in the command line.
The reason you would use this is simple: it makes a batch file look a lot smoother when run.
It does this by not showing the code of a batch file. Here, I'll show you two examples to show the contrast:
WithEchoOn.bat
REM The rem command makes dos ignor the line.
REM This lets you add comments to your code.
Echo Testing
Echo Testing
Echo One, two, three.
This first one should run, but look ugly on your screen. Every command will show on screen, and with its output following it.
WithEchoOff.bat
echo off
REM The rem command makes dos ignor the line.
REM This lets you add comments to your code.
Echo Testing
Echo Testing
Echo One, two, three.
This second one should look a lot better, but annoyingly shows the first command.
The next two should look the same on screen, and all explain why in a sec.
AtEchoOn.bat
@REM The rem command makes dos ignor the line.
@REM This lets you add comments to your code.
@Echo Testing
@Echo Testing
@Echo One, two, three.
AtEchoOff.bat
@echo off
REM The rem command makes dos ignor the line.
REM This lets you add comments to your code.
Echo Testing
Echo Testing
Echo One, two, three.
The reason the code looks the different, but the output the same, is because it's two different ways to do the same thing: keep commands from showing on the screen. You want results or actions to show, and to have control of the screen. The last one is the most important. That's the one you will usually use, but the other is nice for quick codes. One liners liners like the "
Check.bat" just need a single "
@" sign to clean up the screen, but it's a pain to use it all the time when there are lots of lines of code.
Try these out and let me know how it goes, and ask me any questions you have (esp on the rem (remark) command I slipped in there). By the way, we will soon be using the echo command to display instructions, results, and other information to the screen. This is how the user knows how to use the program, after all (one way at least).

13 Jan. 2004 - 17:43
dreamz
ok, i just copied and pasted (so it wasn't too bad!) and i ran them.
1. yes, i saw all the commands.
2. i typed withechooff and i got the output, echo off, testing, testing, one, two, three.
3. this was even better than 2 because it didn't show one extra line "echo off."
4. this looked just like 3.
i'm not sure why you included the remark command. what comments do you add?
the @ was nice, though. i went back and added it to the files i created before. it's still a little confusing, though, so i doubt i could code this all from scratch without reference.
13 Jan. 2004 - 19:51
fallout
when you write any type of code it is usually a good idea to comment what you are doing, that way anyone can tell what is going on especially people that are just learning the stuff or so you can remember why you've done something at a later time
13 Jan. 2004 - 20:26
craeonics
It's also smart to jot down what a batch file is supposed to do inside the batch file, so you won't wonder what a file was supposed to do when you stumble upon it after six months. Comments are rather essential.
dreamz: It boils dow to just a few things.
1) "
@echo on" is the first line of code you write.
2) "
echo text" will show "text " on your screen.
3) "
rem" lets you leave notes in your code.
Here, I'll go a little more into the remark command:
Remark.bat
@echo off
echo Test of the remark command.
rem Note to self with rem used.
Note to self without the rem command.
The last line should give you an error, and everything else should run as expected. Ya see, if you just popped in comments where ever you wanted, it wouldn't be pretty. Usually you just would get a sloppy screen on what could have been a clean running program. It's a small chance, but imagine if you accidentally used a command. Nothing you would want, most likely. The comments let you type in anything you want safely. Makes life easier. Fallout and crae gave the main reasons why you would want to do this. Also, keep in mind that a batch file can be huge. It all depends on what you want to do with it.
Anyway, try this out, and let me know how it goes.
Btw, I'm winging it here. All subjects and code are made up on the spot. No book or anything to go by. I'm having fun with it though.

14 Jan. 2004 - 22:54
dreamz
gotcha. i understand it now.
glad you're having fun. i'm learning so much here.
i'm getting used to writing batch files now, and i'm creating a bunch to load programs, but i'm still not really sure what else you guys do. you did mention earlier something about using commands to show certain processes/info, etc. i only know tasklist and ipconfig commands.
14 Jan. 2004 - 23:02
craeonics
My main use for console is:
- running Ruby scripts
- running command line apps (mostly rom management tools)
- fast deletion of files. Deleting thousands of files with a simple del *.* is a zillion times fast than doing it in the file manager
- running commands like ping, tracert and nslookup to see if my router has crashed (it tends to do that) or dig up info on sites
- replaygain my MusePack files after I ripped a cd
Info huh... hmmm...
Hey XP users, how is the "
mem" command in XP? Doesn't it show anything worth viewing?
You should be able to kill tasks too. I'm in 98 though, so I use 3rd party apps to do this. The first two things I showed you give a lot of info in themselves ("
set" & "
path").
Dreamz: What sort of information would you like to learn? You can make script to display information. I think I got one or two for you though, but I don't know how well they works in XP: "
ping"", "
tracert", and "
net".
Try these out:
ping virtualplastic.net
tracert virtualpastic.net
net
net view
The first too are internet releated, and I'm still learning a lil about each. The second two are for your home machnes network. The single word one should just give you a list or help file. The last one should show any computers on (including your own), plus the description you put in it.

Before you go experimenting with these tools any further, wait for more knowledgeable folks to share so ideas. I'm just introducing some valuable commands, but it's best to know all about them before playing around.
Good questions by the way. Keep them coming. I'm gearing this toward you. What you want to learn, I teach. I'd like to get some logic commands in soon like "
if" & "
choice" so you can do more with your apps.
As always, let me know how the first stuff went, if you understand everything, and what dirrection you want to go. We'll take it from there next time.

15 Jan. 2004 - 13:27
craeonics
Lemme spill what they do before you try:
ping - send and receive 32 byte packets from and to a server in order to see if the server is online and determine if there's dataloss along the way
tracert - trace route, lists the machines your computer jumps to and from in order to reach the requested address, plus their response time
15 Jan. 2004 - 13:29
grigri
the "net" is a very powerful command, if I remember correctly. Just this simple line at the command prompt : "net send * Hello" : annoyed the hell out of everyone at my university (aah, the good old days...

) as it sent a pop-up message to every single computer on the network (hehe this didn't just include the computers in the study rooms, it got all of the computers in the offices and even *gulp* the server). Hours of fun!
Red I'd be interested in learning the control structures (if, choice, ...) in DOS because I've never used them. How advanced are they?
Another great one liner, before I forget. This is a hard drive search/find command that I had once long forgoten about. I go into each tag within it to explain how it works too.:
s.bat
@dir .\%1 /s /p /b
:What it does is...
1) list to contents of a directory ( dir )
2) starting with the one you are currently in ( ./ )
3) by the parameters you enter, ( %1 )
4) then it's subdirectories ( /s )
5) with pauses for each screen of data ( /p )
6) and in "bare" format ( /b )
( bare means - long file name for drive:\path\name.ext )
It's a handy one, esp if you are workingin a dos box already. Also nice if you don't like the new age web style find (like myself). In the end, if you wanted to look for all the mp3 files in your music folder, you would go to your music folder and type in "s *.mp3" and a list would scroll down. Naturally, "s nirvana*.mp3" would list all your nirvana tracks too.
Girgri: I do a lot with them.

They are pretty good, and finally give you some control over a program. It doesn't just run in a straight line anymore. You need the "
goto" command to complete the picture. Most if and choice commands lead to a goto, and that's where it actually does something. There is also a "for" command that will rock for you guys, but not fo a 98 user like myself. Loops are hard to do in dos. No true math functions, and loops have to be macguyvered (you've heard that expression before, right?).
I'm going to start easy. The "if" command is simple to illistrate.
minibackup.bat
@echo off
rem program to make a back up copy of autoexec.bat if one doesn't exist
if not exist C:\autoexec.bak copy C:\autoexec.bat C:\autoexec.bak
Like I said, it's really nice to work with when files are involved. It's designed for this kinda stuff. Here is another way is could have been coded with a little less logic, and some goto commands:
minibackup2.bat
@echo off
rem program to make a back up copy of autoexec.bat if one doesn't exist
If exist C:\autoexec.bat goto end
copy C:\autoexec.bat C:\autoexec.bak
:end
What a "
goto" statement really does is jump to another part of the code. I've only gotten it to reliably work when you are going down a page, but in theory it should be able to access the section whether it is above or below it. It's just:
goto text (where you want to go)
:and then:
:text (where you want to go)
:and you're there. Notice the "
:" in front of the "
text" there. That is what designates a point you can go to. Pretty simple concept.
And this brings up a new point for most long batch files. Most have and "
:end" at the end (possilby with closing instructions after it). This makes it easy for a program to exit itself out without you having to worr about how you what to do it. The ending statement could be anything you wanted, but "
:end" is sort of the norm/standard.
That's most of "
got" & a taste of "
if". I'll go more into if and choice next time. Choice actually uses "
if" & "
goto" to work usually, but there are some ways around that. This is a long post so I'll stop here.
While I have you're ear, how about a c++ thread like this? I'm currently re-learning it, and a thread seems to be a great way to teach ppl willing to learn (if you can find a willing teacher
;)
Dreamz: I know that was mostly aimed at Grigri, but I want you to be able to keep up too. Let me know if that made snese, and, by all means, ask questions. Don't hesitate to ask the old "can I code something to do this?" which always leads to more answers than you bargin for.
One thing i haven't explianed well is the %1 thing to you. That's how you send an argument to a batch file. It's just a special variable. What ever you type after the programs name (not including the space natuarally) will be in that variable. %2 would be the next item after the next space, and then %3 to %9 (you can do beyond that, but it's not as easy). %0 is actually the command itself. How about that?
The %1 thing is also all over the registry. The reason is the same, only the file type you click on is a parameter select by your mouse rather than typed in. I always thought that was a pretty cool lil thing, myself. Good to know.
Let me know, and I can go into more detail.
Guys, feel free to fill in the gaps, give a different way of saying things, or even jump ahead a lil. Things are progressing very smoothly, and steadily. I'm enjoying this thread a lot. (woo to the newbie who just stumbles on it though

) Btw, I just wanted to say a quick thx to all who helped and have listened. It's nice to actual get to talk about DOS for a change with some ppl.
And sheesh, when I'm done, this will be a book.

15 Jan. 2004 - 16:42
grigri
Thanks Red, that clears a lot up!
You're right, the "%1" is everywhere in the registry, meaning the file selected. However, I've noticed that when used via the registry (example Notepad.exe %1) it passes the DOS 8.3 filename to the program. Sure, that's no problem for Notepad, but it does mess things up for certain programs (those tildes in filenames are so ugly). The way around this (registry only, not DOS) is to use %L instead of %1.
15 Jan. 2004 - 23:50
craeonics
Net send is evil!
Example of a for loop, my old .wav to .mpc batch file. The purpose of this batch file was to encode .wav's I ripped from cd's to .mpc format and then delete the .wav's. Note line #2:
set PATH=%PATH%;e:\audio\musepack\enc;e:\audio\musepack\dec
for %%i in (*.wav) do mppenc.exe --standard "%%i"
replaygain --autodB *.mpc
del /q *.wav
Line by line explanation:
#1 - temporarily add the locations of the encoder and decoder (decoder is needed by replaygain) to the path, so they can always be found when I run the batch file
#2 - loop through all .wav files in the current directory (*.wav) and encode them (mppenc is the encoder). %%i is a variable that holds the currently selected file. for goes through each file ending with .wav, puts it into %%i and executes the command that's specified after do, after which it continues with the next file
#3 - after the for-loop, every .wav has been encoded to .mpc. Line 3 does some further processing.
#4 - and then we're done and the .wav's can be deleted. /q means del won't ask for confirmation
16 Jan. 2004 - 04:48
dreamz
well, i don't really know what sort of information. you just mentioned it, so i thought you were going to explain something about it, but maybe things like installed programs, managing running tasks, system info (other than "systeminfo." or is that the only one?)
tried those. i know ping and tracert, but the net view one is interesting. i also tried the search and backup ones too. i went into the windows folder and tried "s *.bat" and i got an error saying that "s is not recognized as an internal or external command, operable program or batch file." if i can get it to work, it'll be a really useful tool for me.
oh, one thing that i would want to learn is closing programs or ending tasks. i already know how to launch with commands, but how about killing tasks? or maybe even combining them? e.g. launching one app closes a running task, and closing that app relaunches the task, or something like that.
and can someone give me a refresher on deletion? i remember my dos days, i'd have to go into a particular folder and do "del *.*" but i think i can just do "del x.yyy" to delete a particular file, right? is there a way to mass delete? but i don't want accidental deletions, so can i get confirmations? does it matter if there are spaces in the filename?
sorry for all the questions.
16 Jan. 2004 - 05:19
beaker
"i'd have to go into a particular folder and do "del *.*" but i think i can just do "del x.yyy" to delete a particular file, right? is there a way to mass delete? but i don't want accidental deletions, so can i get confirmations? does it matter if there are spaces in the filename? "
Yes and yes. Mass delete can be accomplished by either del *.* or deltree foldername. Both will prompt before executing unless you give the switch that you don't want to be prompted.
Quick one for now....
grigri - did you see my c++ idea like this want one? What do you say?
Dreamz - is the s.bat in your path folder? Try just running with that line of code (but no @, as it's a .bat thing).
ok? ok? My friends? I'll have more soon.
16 Jan. 2004 - 12:00
grigri
You want me to do a "learn c++" thread? Sure, I can do that...
Who's interested?
And what level are you? Do I have to start from the top, or do you have some basics? What do you want to do with c++? (Different ways of learning for different types of program)
16 Jan. 2004 - 17:20
dreamz
yeah, red, you were right. i forgot to put it in the path folder. i just left it somewhere else.

but for other batch files, it didn't matter where they were located.
c++? i'll be reading through it, but i have *no* programming experience whatsoever. it might be too much for me, but i'll try it out and see.
16 Jan. 2004 - 20:41
fallout
I'll pitch in on a C++ thread if one starts.
as for what level I am: I have been writing ansi standard C++ since the standard was formed in 98 and borland C++ / Visual C++ / gcc before that
there are many things that I don't know, like writing an extension to windows, but I am good at much of the low level stuff (classes, inherentance, pointers, overloading operators)
GriGri: "%1" is often a solution too.

You just have to be careful that you don't end up with doubles (""path"") which totally screws things up.
And I'm going to try and recall where I wanted to start. Probly with the basics, and what compiler to use. I'll start a thread.
crae: Ya, you can do those, which are great for file manipulation, but not logic coding. NT+ systems can do these and traditional loops... I just forget how.
dreamz: Here is something taken from the link at the top...
"
tasklist (XP only)
Tasklist is the command console equivalent to the task manager in windows.
taskkill (XP only)
Taskkill contains the rest of the task manager functionality. It allows you to kill those unneeded or locked up applications."
Glad you got the thing to work too.

Dunno why it was reading things from just anywhere.
Back to the "
net" command, for each thing it can do, there is a help file. For example:
Net view /?
And you can also use it to view machine shares and such with:
net view \\machine_name
That should take care of tasks. I have third party stuff to do this in 98.

I also set "
t.bat" to tasks, "
q.bat" to quit/close an app (with ".exe" added so ya don't gotta retype it), "
x.bat" to exit the dos box, and "
'.bat" to clear the screen. Makes life a lot easier.

In the end, you just type a lot of single letters to do your most common stuff.
Anothing thing I do is use dos to change/reload shells. LiteStep and GeOShell for instance. The code closes any shell in a list that might be running (in this case just the two), and then starts the new one with the option to not start up anything (which I alway have set). I can share the code if you like, but you aren't an alt-sheller, are ya?
How are you feeling on delete? Think ya got it? Remember you can always do a /? on it for details.

(thx for jumping in beaker

)
Getting to some actual code, here is an example the "
choice" command:
change.bat
rem A little program to edit some common files
echo 1. Open AutoExec.bat
echo 2. Open Config.sys
echo 3. Exit
choice /c:123 Please select one of the above.
if errorlevel 3 goto end
if errorlevel 2 goto config
if errorlevel 1 goto autoexec
:autoexec
notepad c:\autoexec.bat
goto end
:config
notepad c:\config.sys
:end
:Try that out. The "
choice" command above is set kind like this:
chioce options text
:and the order of things takes some getting used to. Te error level thing... I'm fuzzy on. It works... that's all I remember at the moment.

The patern I use to figure it out is like this:
---1
---2
---3
123
---3
---2
---1
:which is a pain, but it works. Basically, 3's are in the center. Keep in mind that the letters are what ever you want (defaul is y/n). It could be "
abc" or even "
`'-=+[]" or what ever you wanted. It just has to be with that "
/c:" tag. I've made whole menus on my own for stuff. You could open like 15 apps on one for my old 386.

Most the other stuff in that file I've gone over, but I can touch on it again. Ask away. That's what I'm here for.

The more you ask, the more useful I feel.
That should be more than enough for now though.
18 Jan. 2004 - 01:23
fallout
I like those task commands, they are the equivalent of ps and kill in *nix which I use all the time
18 Jan. 2004 - 19:17
dreamz
i don't really know how to kill processes, though. there are certain parameters you need to add. and is it possible to combine launching and ending in the same batch file? e.g. launching one closes another and vice versa?
yeah, i think i can delete now. i just didn't want to delete vital files!
can you explain the code a bit? in particular, could you please explain what it does? it's going to different files and finding error levels? and why that particular pattern?
18 Jan. 2004 - 20:37
undefined
dreamz: For taskkill, use the "/im" switch followed by the filename:taskkill /im notepad.exe
To kill and start:@echo off
taskkill /im notepad.exe
start notepad.exe
Also, WinNT+ does not contain the "choice" command. Windows 2000 and later use "set /p" to obtain input:set /p var=
The input section of Red's change.bat would look like:set/p var=Please select one of the above:
if "%var%"=="3" goto:end else (
if "%var%"=="2" goto:config else (
if "%var%"=="1" goto:autoexec ))
fallou: I actually have two apps for killing tasks.

One,
kill.exe asks politely for the program to exit so the app can ask if you want to save a file, record settings, or whatnot. The,
taskill.exe, other just bluntly kills it without it even knowing.

Poof! Gone! Bye-bye! The second is the one I used for "
q.bat" and the first can list tasks so I use the ~no-extra-blurb~ tag on it in
t.bat to quickly list the tasks. I also set my DOS box to the 43 lines mode from the "screen" tab in its properties. This way it always shows the information I need (no scrolling back in 98).
For fun, when my system is close to crashing from lack of resources (like a from a momory leak or an app that didn't close right or whatever) I have "
f.bat" which is set to launch a windows app that nicely frees a custom parameter set amout of ram and exits (btw, I'm renaming soon to either free or ram or both or something, not that it matters much). The stuff I do in DOS.

Have thing set up to sync to atomic time too, and sheesh I got a lota lil things that no body probly wants to hear about.
Dreamz: Ya, it's a crazy little thing, isn't it? The why, i can't explain.

; I'm looking into that. It's a greater than less than thing you. It's basically testing if the number, stored in the errorlevel, is equal to or less than the number it's compaired with (1,2, 3).
Btw, if it doesn't have the "
goto" statements, then it keeps on going down the list as if true. Another part of the crazyness of this command.
What the code does is create a menu. Something a user can pick options out of by pressing a single letter. Let me make on a little more simple (forget about the last one for now):
feeling.bat
@echo off
rem Example of the choice command
choice Are you feeling ok?
if errorlevel 2 goto no
if errorlevel 1 goto yes
:yes
echo Cool. Glad things are good.
goto end
:no
echo Awww... hope you feel better.
:end
:and here is another bit of code for you to think about. The code is based on the one above, but I cut out a portion. The last check it's needed. Remember that DOS is reading this line by line and "
goto" is just how it skips lines you don't want to run. Have a look, and we'll talk about it. No doubt you'll have a question or two on this one. Btw, I don't like the
choice command be cause it is a pain to use, but menus are often needed in batch files. User control or intervention is just something that is required sometimes. Anyway, here is the code:
feeling2
@echo off
rem Example of the choice command
choice Are you feeling ok?
if errorlevel 2 goto no
echo Cool. Glad things are good.
goto end
:no
echo Awww... hope you feel better.
:end
19 Jan. 2004 - 03:01
dreamz
got it!
thanks, undefined! i had to change some code when i realized it wasn't working. and thanks for the other tips.
i can see that in the second one, you cut out some parts, so i assume that the part that is cut out is basically the default, since you only specified errorlevel 2. i.e. it's like, if you didn't put no (e.g. yes), it just says cool. glad things are good.
as for the actual code, i'm on xp, so i had to play around with it a bit, but i finally got it.
my code:
@echo off
rem Example of the choice command
set/p var=Are you feeling ok?
if "%var%"=="no" goto:no
if "%var%"=="yes" goto:yes
:yes
echo Cool. Glad things are good.
goto end
:no
echo Awww... hope you feel better.
:end
since i don't really know enough about the logic and patterns of the code, i fumbled a bit (trial and error), but i got it. i'll have to keep this as a template. but red, those little things sound neat! teach me some of those as well.
another question. i created a batch file to launch winamp, and it launches ok, but after it's launched, i don't have the prompt anymore. all i have is a blinking cursor, so i can't continue typing in the window. i need to click the x to close it. why is that?
19 Jan. 2004 - 03:47
undefined
dreamz: Use the "start" command, instead of just running winamp.exe:start "" "%programfiles%\winamp\winamp.exe"The extra set of quotes is needed to set a (null) title, so that quotes can be used for the path. Otherwise, "start" thinks that the path is the titile.
19 Jan. 2004 - 05:03
dreamz
thanks! it launches even better than before. but how come the same method of scripting loaded firebird well but didn't load winamp as smoothly?
Dreamz: Going to do a quick post. You get the window up there still because you have to select "close on exit" in the properties of the batch file (right click on the file or the title bar after it's run). That should fix it. I think it was don so that you got a change to see whatever info might be there. You might be able to have it taskkill itself, though. I've never tried it.

Most of my batch files are run from the dos box dirrectly, so I don't worry about it.
Excelent job on writing your own code. Making minor adaptations and experimenting really help a lot for you to learn how to code.
Btw, this reminds me. Try these two lil lines and let's see what comes up for xp. Post back the results so I can see them (being on 98 and all), if you could please.
Undefiend: Thanks for clearing that up. I always wondered why they took out a command that useful. I set that the scripting became a bit more *nix or even c like in it's abilities.
20 Jan. 2004 - 00:23
dreamz
yeah, it was fun to play around with it too.
red, you should make a list of all the batch files you've made (provided it doesn't run into the high double-digits!

), hehe. maybe i'll try them all out.
and what two lines?
i took a look at the c++ thread and it just went right over my head. O_o
20 Jan. 2004 - 02:49
undefined
dreamz: What do you mean by "smoothly"?
Also, if you want to see a bunch of batch files, take a look
here, or just open any bat or cmd file you already have and take a look inside ("dir/b/s \*.bat \*.cmd" from the command prompt). If you have any questions about the code, I'm sure we'll be able to answer it.
Red: I agree, scripting has become more powerful, but not without its own set of bugs and workarounds

.
I have to say I'm surprized how well this thread is doing. There are a lot of great posts, and it seems like there is plenty of life left in it. It's deffinately been worthwhile reading too. And I wonder why this is my fav forum? It's actually worth reading. ^.~
Dreamz: Ack, I must have accidently delete or miss taged them somehow. Here they are:
cmd /?
command /?
:they should show what they can do, more or less.
Another little tip: in cmd.exe you can press up to get to your previous comands. In command.com, you need to install doskey to do it (I include the /insert tag for easy typing).
I'll throw my batch files all up here soon, and make them availible for download. I think you'll be impressed. It makes using dos a lot easier and faster to me. Curious to see if anyone else has scripts like these, or ideas to improve them (including you).
Don't worry about the c++ thread. When you'r ready, start your own.

They're going on what I know, and I've coded in more languages than I can recall.
Undefined: Ya, that's often how it goes with these things.

Checked out the link too, but I really didn't see anything too grand. What was it supposed to find?
20 Jan. 2004 - 16:41
undefined
Red: The link was just incase dreamz wanted to take a look at some scripts made by others. Most of the files are quite basic, but they show alternate methods of doing things.
20 Jan. 2004 - 19:16
dreamz
yup, tried those two commands.
cmd /? says "starts new instance of the windows xp command interpreter" and lists several pages of text, including registry entries and commands. there must be a way to export all that to the clipboard or a text file.
anyway, command /? is much shorter, "new instance of the ms-dos command interpreter." there are only a handful of options: [drive:]path, device, /E:nnnnn, /P, /C string, /MSG.
20 Jan. 2004 - 19:48
craeonics
Command is old, cmd is new and improved. Anyhow, remember that redirection thing mentioned earlier? Try it:
cmd /? > dump_this_shit.txt
You can then open that text file and read it at your leasure.
20 Jan. 2004 - 21:17
dreamz
yeah, the first thing i tried was the redirection method, but the output was messed up. i must have typed it in wrong or something, but i'll try it later when i'm out of class.
well, something else i was wondering, but the xp users will have to tackle this one, is how to use batch files to turn certain services on and off.
21 Jan. 2004 - 05:32
fallout
if redirection doesn't work, you can always pipe it
21 Jan. 2004 - 05:44
dreamz
yeah, redirection worked. i typed it wrong the first time.
21 Jan. 2004 - 11:54
grigri
Just a quick note: if you use ">>" instead of ">" then it appends the output to the end of the file... very handy
22 Jan. 2004 - 01:31
dreamz
ahh, thanks for that note, grigri.
is there a timer command anywhere? maybe i could launch something and then use the taskkill function later, but i want to specify the time.
and is there a way to control certain programs from the command prompt window? e.g. winamp.
i hope you guys aren't annoyed by these questions. i'm just going through my day and coming up with commands i'd like to see implemented. thanks, everyone.

23 Jan. 2004 - 20:23
Targaff
Going back to the comment about using a console in nix earlier, I highly recommend downloading
UnxUtils to provide extra functionality to your console window. It provides proper ports (as opposed to that other one that uses Cygwin) of some of the more fundamental commands missing from DOS. Grep is a particular favourite of mine...
One other thing I've done for a long time now, too, is create a \utils directory and add it to the end of my system path. It contains all the little apps I've collected over the years, most notably command line archivers but also some other stuff. Mostly cmdline archivers, though

24 Jan. 2004 - 01:42
undefined
dreamz: To start / stop services, use the "sc" or "net" command, after obtaining the service name by running "sc query":net start servicename
sc stop servicename
For the timer, you can use the "at" command.
There isn't a built-in tool to control applications like Winamp, unless the app has command line options.
24 Jan. 2004 - 02:26
methodik
targaff: those unixutils are a good tip to post here. i had those installed on my old system, had completely forgotten about reinstalling them on xp here. grep, in particular, is absolutely vital. ( although probably particularily difficult for anyone not familar with it. )
24 Jan. 2004 - 02:30
methodik
i was actually just thinking, command line tools to totally control winamp are so easy to do it's laughable. code them up, throw them in a \utils directory or somewhere in the path, and away we go.
if anybody would be interested in them, they'd take no time at all to code up. play, stop, ff, rewind, open, etc. external winamp control is extremely well documented.

24 Jan. 2004 - 07:24
dreamz
thanks, undefined! for some reason, the printer spooler service isn't listed. oh well. but i'll definitely keep that command in mind.
what's grep?
how do you code such controls for winamp? right now i'm using remote control exes that i downloaded, but they're only used to go back, forward, stop, and play, so nothing complicated like jumping to a certain song, and so on.
24 Jan. 2004 - 14:02
Targaff
Incidentally, I also have ports of ps, pv and kill here, though I haven't a clue where I got them from now. If anyone wants them, just let me know.
Here's a batch file I wrote earlier this year using sed, let's see if anyone can work out what it's for
@echo off
IF "%1"=="/?" GOTO usage
IF %1x==x GOTO usage
IF NOT EXIST %1 goto nofile
IF %2x==x set cbout=out.tmp
IF %1==%2 set cbout=out.tmp
IF %cbout%x==x set cbout=%2
sed "s/\x20ADD_DATE=\x22[0-9]*\x22//;s/\x20LAST_VISIT=\x22[0-9]*\x22//;s/\x20LAST_MODIFIED=\x22[0-9]*\x22//" %1 > %cbout%
if "%2"=="out.tmp" goto end
IF NOT "%cbout%"=="out.tmp" goto end
del %1
ren %cbout% %1
goto end
:nofile
echo.
echo File not found - %1
goto end
:usage
echo.
echo CLRBOOK filename [filename]
:end
set cbout=
That uses sed, btw, one of the UnxUtils tools I mentioned. Grep is similar in that it searches for a specified pattern in a file or files and tells you where it is, though i'm not sure whether it can be used to replace stuff as well, I haven't used it enough to know yet.
24 Jan. 2004 - 19:05
dreamz
i can't figure out what it's for.
sed? ps? pv? kill? O_o
24 Jan. 2004 - 19:16
methodik
dreams: <ahref="http://www.winamp.com/nsdn/winamp2x/dev/sdk/api.jhtml"> winamp API. using that api interface you can actually code up fairly advanced remote control exe's for winamp, that go beyond the simple play, stop, etc.
targaff: if you wouldn't mind sending those ports of those three tools you have, i'f be grateful
24 Jan. 2004 - 23:25
Targaff
Files available
here.
dreamz: it's probably a bit obscure for what's already been covered here, but it basically clears unnecessary stuff out of a bookmarks.html file, most particularly the add_date and last_visit things browsers like to add to their files. Usually reduces the file by a quarter or so (also makes it unusable by the browser, but hey...)
pv is a command line process viewer; kill lets you kill applications from the command line (like taskkill, presumably); ps gives more info on processes running, but I can't remember what it stands for off-hand. Something important, I'm sure.
I mentioned Nivenh in another thread and I'll mention
his site again because it has a nifty eConsole spin-off called Console2 on it. Alternatively, there's Console on
sf.net, which was considerably quicker, however the version I had (latest beta) crashed when I tried to set a background picture. Works fine otherwise, though.
25 Jan. 2004 - 02:07
dreamz
ahh ok. it was too complicated considering how i just started learning all this.
console2 is nice. that's what i'm using now, but the typing is a little slow.
25 Jan. 2004 - 04:53
methodik
i gotta say - i know console2 is pretty cool, nice and transparent and such, but i just found a new love for it: running an alternate command shell.
i ended up after d/ling the original console seeing a reference to ksh ( kornshell ) in the readme. which in turn got me doing some digging, and turned up
UWIN, a cygwin like unix tool set that integrates itself far deeper with windows than cygwin does.
so, to make a long story short, i now have console2 with all it's transparent eye candy running a ksh shell that is so well integrated with the windows file sytstem so as to make it very, very useful.
25 Jan. 2004 - 17:59
dreamz
ooh, maybe you can help me with configuring console2. how do you get rid of the scrollbar? how can you use the scroll wheel to move up and down instead (it doesn't work). and for some reason, i've played with every setting in the xml file, but i couldn't make the text white. O_o
25 Jan. 2004 - 20:14
methodik
scroll-bar: appearance / border - change the setting to none.
scroll wheel: doesn't work inside console2.
font-color: font / color - first, remove the enclosing comment brackets from around the color line. those 255/255/255 settings are white. however, if your transparency is very high, then your white will be transparent as well, meaning that it won't look white.
hope that helps.
25 Jan. 2004 - 20:56
dreamz
scrollbar: it was already set to none, but i still have the scrollbar.
wheel: i guess there's no way to use the wheel then.
font: i tried what you said, but the font is still black, even when transparency is turned off. not sure what i did wrong. the only way i can use console2 is if i turn off aliased fonts, which makes the window white and the font black.
25 Jan. 2004 - 21:17
methodik
dreamz, what are you running console2 on?
25 Jan. 2004 - 21:24
dreamz
25 Jan. 2004 - 21:26
undefined
dreamz: I don't use console2, but you can probably remove the scrollbar by running "mode con lines=15".
25 Jan. 2004 - 22:32
methodik
er, yeah. i didn't think about the buffer.
it's changeable from the .xml file by changing the buffer from 1000, to whatever matches the number of rows in the setting preceding that.
26 Jan. 2004 - 05:08
dreamz
yeah, the buffer change did it. unfortunately, i couldn't maneuver through the command window anymore. arrows and page keys didn't work.
but i still can't change the font color. oh well.
27 Jan. 2004 - 18:21
dreamz
i took a look at that winamp coding page. considering how i have no background whatsoever, i couldn't understand most of it. maybe there are already completed scripts/apps i can find online.
27 Jan. 2004 - 23:32
beaker
A series of WinAmp COM apps have already been created, kmr uses them for his html WinAmp control. They are available here:
http://www.adcock8.freeserve.co.uk/
If for some reason the site is down (can't check it here at work - I got an access denied message from the proxy), I'll email it out.
27 Jan. 2004 - 23:55
dreamz
hey thanks. i downloaded it. it's a
dll plugin, but i don't know how to use it. i'll have to look into it more later.
They have some instructions else where on the page I believe.
Here is an interesting little trick for you though. You know what LiteStep is, right? Well, there is a program that lets you run bang commands from the command line. I renamed mine to "!.exe" and you can use it to control litestep. Tthough it would take either some customization to LiteStep to create simplier bang commands, or some coding to create a batch file to do the simpliying for you, you could come up with a working system. A .bat file would be nice to just do say...
! play
...and have winamp play. The advantage would be to incredible number of things LiteStep can do with plugins and other wise.
Hey, semi off topic, but is there a way we could have !bang commands understood like http or www by DOS?
28 Jan. 2004 - 03:22
dreamz
yeah, i read the readme, but it looks like you need to know programming O_o
i know litestep. i used it before, but then i stopped after a theme messed up my system, so i've only heard a little bit about bang commands.
28 Jan. 2004 - 03:35
beaker
I have them compiled as executables...not sure where I got them then. Maybe it was kmr who built them. Point is, if you'd like to email them to you, just leave a message.
28 Jan. 2004 - 03:42
dreamz
oh, i didn't know they were already compiled. could you send them my way then? chlumpc at hotmail dot com
hopefully it won't flood my inbox.

thanks a lot. much appreciated.
another cool command would be firebird control. i find myself having to refresh 10 pages when i surf forums. there should be a way to type a command and have all the pages refresh at once.

28 Jan. 2004 - 04:42
beaker
28 Jan. 2004 - 05:15
dreamz
thanks!
oh, i know, these are the play, next, prev, stop exe files. i have those, but thanks. these are better because i had to install the other ones. standalone files are always nicer.
do you know how to get other functions like jump to file/time, add to playlist, etc.? or would i need to code those?
Code or LiteStep !bangs. This is where things get complicated and require more work. The firebird thing might be a feature idea for the app itself (rather than a cmd line thing). These apps that can do these nifty things can only do them because they have been coded to accept commands from outsite apps. Not everything can do it, though vb scripts do expand possibilities (since they can similate key strokes).
Here is a quick lil batch file use to get to my c drive and navigate it (I also created one for my d drive, which is also my desktop)...
C.bat
@echo off
if not '%1'=='' goto directory
c:
cd c:\
:
goto end
:
:
:directory
c:
cd c:\%1 %2 %3 %4 %5 %6 %7 %8 %9
:end
All you have to do is type "c" to get the root c drive or "c folder" to get to the folder you want. I hardly ever touch the "cd" command now
30 Jan. 2004 - 01:43
melaleuca
Firebird has a way to refresh tabs. Mine does anyway and I think you need to have the
tabbrowser extensions installed to get this behaviour. From the tab -> tab features menu (and also on the individual tab's content menu if you configure it that way) you can set a tab to "auto reload" however many seconds. There is also an option to "auto reload all tabs" so all 10 pages will be refreshed.

Don't know how to do it from the command line, tho'

30 Jan. 2004 - 04:13
ninja_01
red try this one
@echo off
c:
cd\%1
We might have to get into windows scripting. It can be done, really. It the ability is there, a method should exist for us to switch to an app, simulare key strokes, and do what we want.
The winampCOM allows to get access to winamp features from windows scripts, so you don't have to code unecessary things.
Once you downloaded the
dll from the site beaker posted and put it into the winamp plugin folder, create a new text file as a .js file, then type:
objWinAmp = new ActiveXObject("WinampCOM.Application");
objWinAmp.FastForward();
objWinAmp = null;
Exexcuting this file (in your case: from the command line), will make winamp go to the next song.
Other things you can do (assuming you know just a little programming), sumarized in this
text file. So for example to set Shuffle on just do:
objWinAmp = new ActiveXObject("WinampCOM.Application");
objWinAmp.ShuffleStatus = true;
objWinAmp = null;
Adding songs to the playlist is done this way:
objWinAmp = new ActiveXObject("WinampCOM.Application");
objWinAmp.AddFile("c:\\mp3\\coolsong.mp3");
objWinAmp.AddFile("c:\\mp3\\coolsong_2.mp3");
objWinAmp = null;
Ask me if you want me to explain more.
30 Jan. 2004 - 05:48
dreamz
nice script, red. i'll have to save that one. do you know of any methods? what kind of windows scripting?
melaleuca: i don't really want to specify a time for them to reload. i was hoping for a way to type a command and them refresh that way, so they refresh when i want them to, and not just at specified intervals.
kmr, thanks for the explanation. just what i needed to learn, but unfortunately, i don't know any scripting and it goes right over me. how do i implement the ones with the numbers? i'm sure if you give me the basic outline, like a template, i could code up most of them. e.g. how do i bring up the jump to file dialog? it's the dialog that pops up when you press j, allowing you to load up a specific song in your playlist.
I think what you need is a line by line explination on those codes.
First line --- this is why it's there
Second Liine --- this is what it does
Thrid Line --- this is why you can't forget this one
Etc. Seems like the first one activates things some how, the second does the actual work (like a command does), and the last one ends the process. Where to get a list of "commands" is beyond me... ok wiat, looks like it's in the text file, but I would have to really read over it to figure it out.
As for scripting, I don't know much myself. Never got into it yet. It's always has be on my list, but it's a long list.
As for the refresh thing, my guess is the feature is sitting unseen in a menu. Exactly want you want sounds like it is right there. Perhaps you over looked it. Maybe melaleuca could show a screen shot of where it is.
Here is another script for you. This one simply sends a search to google for you. This one also introduces the concept of error checking in your program. It doesn't do much though. It just exits if you don't type anything (any parameter that is) after the filename. Have a look...
g.bat (google.bat would work well too)
@echo off
:Google search app by CutTheRedWire
:Let you do a search right from the run box.
:Some minor error checking
if '%1'=='' goto END
:Google link with search words.
start http://www.google.com/search?q=%1+%2+%3+%4+%5+%6+%7+%8+%9
:END
...and tell me what you think. This one also has actually useful comments. If you want a sort of "homework", think of a way that it could show an error message only when an error was found.

Should ba a handy batch file in anycase.
Notice I keep a lot of my life names down to a single letter for batch files. Obviously this makes them faster to type, but obviously you only have so many keys on your keyboard. Try not to worry about it. Jusr rename things as time goes by. Decide on a back up name to make the transition easier. Like if you one day get a g drive, google would make a great back up name.
Alright then. Red you're right you can forget the first and last line they are just initialisation and uninitialisation. Basically creating/destroying an object that controls winamp.
objWinAmp.SendCommand(40194);
Will bring up the jump dialog. I know it's not so user friendly, but that number is just a code for that particular action.
30 Jan. 2004 - 21:34
dreamz
hey, that's a really good script. simple, fast, and of course, useful. thanks!
melaleuca, could you point out exactly where i could find those settings? i've got tbe. red's probably right. i must've missed it.
yeah, i looked at the text file, and the first and and last lines are always the same. the middle one is the crucial one, but it's hard to understand how to code it. thanks for explaining it to me, kmr and red.
thanks a lot, guys. i'm learning so much here.

I'm not sure how to code it either. That's why I use the...
Bold Letters for the File Name and.Extension
and the italicized text for the code
Then back to normal text to show that's all that goes on the file. It greatly clarifies things.
Anyway, let me take a shot at this one using my method, and we'll see if it's easier to read. Here is what the code would look like for the last thing our old buddy kmr gave us...
Jump.js
objWinAmp = new ActiveXObject("WinampCOM.Application");
objWinAmp.SendCommand(40194);
objWinAmp = null;
And I always tell how it it used too, so in this case we would type in "jump" and it should bring up the jump dialog box. I haven't tried it out though. I'm hoping kmr can verify this before we continue.
In the mean time, here is a little script that I know will work. I know because I wrote it.

Actually, I'll give you a few...
...Clear off you'r screen a lot faster...
'.bat
@echo off
cls
...Exit the DOS Box a lot faster...
x.bat
@exit
...Edit your batch files a lot faster...
bat.bat
@echo off
Notepad.exe C:\Path_To_BatchFile_Folder\%1.bat
The last one you would write say "bat g" to open the google batch file in a windows text editor. Personally, I use metapad, but you are probably using notepad.
31 Jan. 2004 - 16:29
methodik
see, now that's one reason i like a unix shell - the alias command lets you easily be lazy without writing batch files.
on my u/win setup i have about a dozen aliases defined when i login, everything from simple program shortcuts to windows commands like system info, grep'ed to produce only the system uptime.
31 Jan. 2004 - 21:22
dreamz
yup, i managed to write up a bunch of winamp scripts. yay! i wrote it up as soon as kmr explained it (i was so eager!) and it worked. very nice!!
very useful scripts. /me copies. how can you remember all these scripts? i'm sure you have at least 100 by now, or is that underestimating?
hey, meth, would you mind sharing your xml files? i can't seem to get the configuration right. i want a black transparent screen with white text, but no matter how i do it, it doesn't work. it looks messed up:
http://screenshots.haque.net/screenshots/view/9903/screenshot-9903.jpg
what's weird is, changing the font changes how the window is displayed. sometimes it'll be all white, and sometimes, half is white and half is black. it's odd.
also, i'm using console (not console2), since it's basically the same, but slightly faster, but the xml code is the same.
my xml:
<?xml version="1.0"?>
<console change_refresh="10" refresh="100">
<font>
<size>8</size>
<color r="255" g="255" b="255" />
false</bold>
false</italic>
<name>Verdana</name>
</font>
<position>
<x>100</x>
<y>100</y>
<docked>none</docked>
<snap_distance>-1</snap_distance>
<z_order>regular</z_order>
</position>
<appearance>
<hide_console>true</hide_console>
none</border>
<taskbar_button>normal</taskbar_button>
<mouse_drag>true</mouse_drag>
<size rows="25" columns="70" buffer_rows="not used" />
<transparency alpha="150" inactive_alpha="150">alpha</transparency>
<color r="0" g="0" b="0" />
<tint r="0" g="0" b="0" opacity="20" />
<!-- back.bmp</image> -->
</background>
<cursor>
<color r="0" g="0" b="0" />
<style>XTerm</style>
</cursor>
</appearance>
</console>
I actually might ignor the alias command. I can use it in DOSkey, but never do. I like having tagible files to open, modify, and improve. Still, for a few of these commands, I might mess with aliases.
What aliases do you use, Meth? Maybe they would make useful batch files.

31 Jan. 2004 - 21:23
craeonics
red, you nut, cls is only three characters long!
Ya, but they are each on opposite sides of the keyboard, and then across from the enter key. That takes to long esp if you are typing one handed. The apastrophy is right next to the enter key. You virtually press one key to clear the screen.

01 Feb. 2004 - 04:32
methodik
hmmm.... my aliases are mainly for usage within an instance of kornshell. ( unix shell, kinda like bash )
i find that since i've installed the u/win package, i'm really really happy with the state of console computing on windows. it makes using window essentially just like using *nix, as it allows you to work within a windows enviroment, with pure unix commands.
so therefore, some of my aliases are going to be of no use to you in the dos world.
one of the most interesting use of aliases is to be able to grep ( or find, in dos ) the output of windows commands like system info to return specific information.
oh and crae, anything that allows console users to be lazy is always cheerfully accepted. if you google for the unix comamnds 'ls' and 'alias' one of the most common examples is to use alias to replace the ls command with 'ls -a' , which shows all files...

01 Feb. 2004 - 18:12
dreamz
hey, meth, i'm using console now (not console2). it's almost as configurable, but it's faster, and you can scroll in the window. i like it more than console2.
maybe you're interested:
http://sourceforge.net/projects/console/
01 Feb. 2004 - 21:12
craeonics
Speaking of Console (or Console2 for that matter). Has anyone ever got tinting to work? The only thing that works for me is setting a backgorund colour and flicking on alpha.
02 Feb. 2004 - 00:19
dreamz
i can't tell if i got it to work or not.
try changing the font. i know some fonts are especially troublesome.
sometimes i tweak it, and it's all white, but other times, it's half white, half another color:
http://screenshots.haque.net/screenshots/view/9903/screenshot-9903.jpg
it's a little funky, so i've just settled on having an all white window with black text, the only way it's readable.
02 Feb. 2004 - 02:10
melaleuca
OK screenshots up...
With TBE installed, you should have a Tab menu with a Tab Features item. That opens a submenu with Auto Reload All Tabs as the last item. See
http://www.mpower.org.au/firebird/tabmenu.png
In the above screenshot, you can see the second last item on the main menu: "Edit Context Menu..." This gives you some custimisation of the context menu of the tab. You can include Auto Reload All Tabs so that you can right-click any tab and get all tabs to refreshed. See
http://www.mpower.org.au/firebird/tabcontextmenu.png
I hope that makes things a bit clearer. Someone with more clues will have to tell you how to script it although I am guessing it would be easier through the Tab menu than the context menu.
02 Feb. 2004 - 02:40
dreamz
hey, yeah, the context menu! thanks for pointing that out. i'd forgotten about it long ago, but there's the reload all tabs feature and there's the auto reload feature. just what i needed. thanks!
maybe there's a way to script it, hehe.
i managed to figure out what was wrong with my console. i had previously tweaked the normal cmd app, and apparently that caused the problems with the console frontend. i didn't exactly get everything right, but i did find some cool results.
02 Feb. 2004 - 07:59
methodik
dreamz - thanks. i actually already have console ( along with the source to both it and console2 ), but i prefer console2 as it adds some refinement to the program, and i don't notice a loss of speed.

02 Feb. 2004 - 23:27
dreamz
hehe cool, but the scrolling in console is really useful for me.
i managed to achieve a really neat effect. it's like fake transparency, only more extensive. basically, the whole window is completely transparent, except for the text, which is opaque.
here:
http://screenshots.haque.net/screenshots/view/9992/screenshot-9992.jpg
if the command window is on top (e.g. of my firebird window), it'll be clear, but the text will simply be superimposed in the other window. i didn't think it was possible, but it looks nice.
do you know of any good console fonts?
03 Feb. 2004 - 00:28
methodik
hmm. haven't played around with the fonts for console(2) at all, as it looks pretty good as is on my box. i actually prefer only a slight (80%)active transparency, as it increases useability on a varied color wallpaper.
crae, i haven't messed with the tinting at all. i should tho. i'm going to send a request to the coder to allow for setting a color from the command line when launched. this would allow setting up shortcuts to launch various colors of consoles - much like i have with aterm on 'nix.
03 Feb. 2004 - 03:41
dreamz
what font are you using? lucida console?
ahh, i always have white/light backgrounds, so it doesn't affect me much.
if you have the source, doesn't that mean you can go ahead and tweak the app yourself? i wouldn't know anything about it, but maybe you coders can mod it, hehehe.
oh, this may seem like a newbie question, but how can i get to different partitions with the console? e.g. browse my d: partition and whatnot.
03 Feb. 2004 - 21:24
beaker
dreamz. Just type "d:" (no quotes).
03 Feb. 2004 - 21:32
dreamz
d'oh, silly me. i was trying all these other things, haha. thanks, beaker.

05 Feb. 2004 - 00:24
methodik
dreamz - yes, it does mean i can mod it. however, seeing as it is really just a wrapper for cmd.exe, there's not to much that's exciting to mod.
i had more fun with the source to a little known console replacement called reactOS. i was actually able to extend the internal command interpreter to include custom commands. ( aka xbar type stuff ).
i've also been working on a alternative shell that is based around a console. has a 66% wide taskbar that sits at the bottom of the screen, and the console slides upwards to become visible, and slides back down out of the way.

05 Feb. 2004 - 00:52
dreamz
ahh, i was thinking that, if you ever found something you didn't like with console, you could tweak it yourself.
your shell sounds neat! i'm hoping i can run it on top of explorer. i wonder if it's skinnable.
is it possible to use the console to load up certain documents? e.g. type "word" and after it, a specific document "file.doc"? e.g. with the browser launching script, it's possible to add %1 after it so you can type in the url. is there something similar for word?
07 Feb. 2004 - 18:15
dreamz
sorry to bump, but i was wondering how i could use 400318 : jump to file or some wildcard with winamp.
is it possible, for example, to type something like "jump stream" where "stream" is the part of the file name and have that song load? thanks.

ofcourse you can

gimme a sec.
// open the jump window
objWinAmp = new ActiveXObject("WinampCOM.Application");
objWinAmp.SendCommand(40194);
objWinAmp = null;
// prepare to send arguments to it
WshShell = new ActiveXObject("WScript.Shell");
WScript.Sleep(500); // wait 500 ms
WshShell.AppActivate("Jump to file");
// send each argument with a space between them
for (i = 0; i < WScript.Arguments.count(); i++) {
WshShell.SendKeys( WScript.Arguments.Item(i) + " ");
}
// send enter key
WshShell.SendKeys("{ENTER}");
WshShell = null;
07 Feb. 2004 - 22:00
dreamz
wow, kmr, you rock! making my fantasies into palpable realities.

thanks, man!
the script looks so complicated, though. do i merely code up something similar to do similar functions?
np. Well it's kinda advanced yeah.
The first steps just bring up the dialog as usual, then I use the sendkeys function to type the text that's passed as arguments to the script. You'd use something like that to have command line arguments that change the behavior of the script. Sendkeys is somewhat of a hack, because it's not very direct, you just simulate keystrokes and hope it does what you intended, but it will work it most cases.
08 Feb. 2004 - 18:04
dreamz
but then if you're using sendkeys, it'd be possible to code up scripts that require similar inputs. basically, if some function has a similar action (load up dialog, type, enter), then i can use that script you posted, but change a few parameters, right?
could i do the same technique with batch files? %1 works great for loading websites, but how about pictures, documents, etc.?
also, does anyone know how to do a more extensive chkdsk in the console? in xp, you can go to my computer > right click the drive > properties > tools > chkdsk and scan for bad sectors as well. i was wondering how i could do that in the console. /r doesn't work, since you need to schedule it after a reboot. it's weird that the gui method lets you scan it, but the cli method doesn't.
15 Feb. 2004 - 13:10
spyder
16 Feb. 2004 - 02:02
dreamz
thanks, kmr. i'll have to write some more up when i get around to it.
and thanks, spyder, for that link. looks useful indeed.
i'm really happy with what everyone's contributed and all i've learned thus far. thanks, everyone.

18 Feb. 2004 - 05:24
dreamz
another question. with the search script above, the file extension is required. is there a script i can use that just takes in any input? e.g. i type in "chinese" and it brings up a list of files with chinese in the filename.
18 Feb. 2004 - 15:50
methodik
this thread has seriously become a book in itself. yay for VP!

Please log-in to post.
You need to be logged in to post. To log-in, or to register an account go -
there.
Options