DOS commands
Blitz3D Forums/Blitz3D Programming/DOS commands
| ||
is it possible start a command in DOS from a bb program? |
| ||
I believe people have done it by writing a batch file containing the commands and then invoking that with execfile. |
| ||
ohhhh... THX! |
| ||
Yeah, I've written out a batch file then done Exec on it. It works, but you can't help feeling there should be a more elegant way. I tried ExecFile <"cmd.exe" + cmdline>, but it didn't work. |
| ||
Maybe someone could make a dll for it? Sorry to ask, but I have no clue how to make a dll... |
| ||
try execfile "command /c "+ doscommand$ /c is to close the prompt after completion. |
| ||
Wow! It works.doscommand$ = "Dir /s > C:\text.txt" ExecFile "command /c "+ doscommand$ End Finally. Thanks, jfk. |
| ||
Remember it's command.com on win9x and cmd.exe on 2k/XP :) |
| ||
there's a link from "command" to "cmd" on XP. In fact you need to use "command" on XP, if I remember correctly. |
| ||
You can run command on XP but it gives you horrible old dos command.com instead of the XP console. On XP cmd works just fine as any other NT based OS (and that's the one you should use on those) |
| ||
@ozak & jfk. In fact cmd does not works on (my version of) XP. Which threw me for a long time. But command does work. And why would I want an 'XP console'? (again, baffling, I've never seen one) - what I want is to invisibly call Dos commands. |
| ||
Yes, someone made a DLL not so lang ago. Unfortunately the forum search is currently disabled (?) Additionally there is a file named "runfile.exe", that can be used to invisibly run command.com :) Just search the web. |
| ||
Thanks, all. |
| ||
Sorry to bump a fairly old thread, but I struggled with this even after reading the advice here. I worked it out eventually (I haven't coded for ages so it took a while!) I'm making an image gallery and wanted to avoid typing all the image names and links so I came back to Blitz to generate a list. I found out that the dos "dir /b *.jpg > list.txt" would generate the file list and I sussed out a simple Read/Write routine to get the links generated but... On XP I could use either Command or CMD but to use long file names I had to use CMD otherwise I ended up with names like "050802~1.jpg" instead of "050802LongFileName.jpg" which was rubbish. You'll probably tell me I could have done the whole thing in Blitz but... |
| ||
Putting aside the problem of actually 'pointing' to a specific folder (I'd use BlitzSys for that) you need something like this:myDir = ReadDir(fold$) Repeat f$ = NextFile(myDir) Print f$ Until f$ = "" CloseDir myDir |
| ||
Yeah I knew it would be easy enough, thanks. I just came at the whole thing so fast and dissorganised that I was thinking on my feet: "Ah, that'll list all the files, excellent." (Not sure how I found it actually, pure chance I think) "That's great, but I've got to add the link bit's either side and then the thumbnails... Simple string manipulation! I could use Blitz..." "Now if only I could do it all in one click... Copmmand line in Blitz or call Blitz from the batch file...?" I haven't really done much with files in Blitz so I didn't give much thought to it but it makes sence now, so much neater and only one file output. Oh well! Thanks to all who inspired! |