DOS commands

Blitz3D Forums/Blitz3D Programming/DOS commands

RRK1020(Posted 2005) [#1]
is it possible start a command in DOS from a bb program?


Perturbatio(Posted 2005) [#2]
I believe people have done it by writing a batch file containing the commands and then invoking that with execfile.


RRK1020(Posted 2005) [#3]
ohhhh... THX!


John Blackledge(Posted 2005) [#4]
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.


RRK1020(Posted 2005) [#5]
Maybe someone could make a dll for it?
Sorry to ask, but I have no clue how to make a dll...


jfk EO-11110(Posted 2005) [#6]
try

execfile "command /c "+ doscommand$

/c is to close the prompt after completion.


John Blackledge(Posted 2005) [#7]
Wow! It works.
doscommand$ = "Dir /s > C:\text.txt"
ExecFile "command /c "+ doscommand$
End

Finally. Thanks, jfk.


ozak(Posted 2005) [#8]
Remember it's command.com on win9x and cmd.exe on 2k/XP :)


jfk EO-11110(Posted 2005) [#9]
there's a link from "command" to "cmd" on XP. In fact you need to use "command" on XP, if I remember correctly.


ozak(Posted 2005) [#10]
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)


John Blackledge(Posted 2005) [#11]
@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.


jfk EO-11110(Posted 2005) [#12]
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.


John Blackledge(Posted 2005) [#13]
Thanks, all.


Forklift_Fred(Posted 2005) [#14]
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...


John Blackledge(Posted 2005) [#15]
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



Forklift_Fred(Posted 2005) [#16]
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!