1.

Solve : How to input line commands in another program from DOS?

Answer»

Hi, I've been reading your posts, but I couldn't find a problem similar to what I have. I'm trying to create a DOS FILE to input line commands in another program, FLUENT. FLUENT has a line command like DOS, and I wanted to create an executable or .bat file to open (a simple START Fluent.exe), and then input commands to the fluent command line. For example, something to write FILE in FLUENT's command line. Any ideas would be very much appreciated!

Thanks,
IsabelWelcome to the forum dude,

Basically, DOS or XP's prompt (which I guess is the OS your using) won't 'input' commands like that. The closest thing I think you'll get to is to use command line switches written into FLUENT.

The best way to tell, is to open a dos prompt and navigate to the folder that contains the FLUENT .exe file and type 'fluent.exe /?' and see what happens.

Hope it helps.
Hi, thanks for your reply. I've tried it and it doesn't return anything. I've tried to give commands through strcmd but it didn't work either! Any other ideas?

Thanks,
IsabelI'm no expert, but I'd say that it's unlikely to work. sorry


Someone please prove me wrong!!!!Not 100% either but you could try this:

Batch file:
Code: [Select]start "" FLUENT.exe
start "" script.vbs
Script.vbs:
Code: [Select]set WshShell = WScript.CreateObject("WScript.Shell")
WScript.Sleep 5000
For i = 1 to 1
WshShell.SendKeys "{C}"
WScript.Sleep 500
WshShell.SendKeys "{o}"
WScript.Sleep 500
WshShell.SendKeys "{m}"
WScript.Sleep 500
WshShell.SendKeys "{m}"
WScript.Sleep 500
WshShell.SendKeys "{a}"
WScript.Sleep 500
WshShell.SendKeys "{n}"
WScript.Sleep 500
WshShell.SendKeys "{d}"
WScript.Sleep 500
WshShell.SendKeys "{ENTER}"
WScript.Sleep 500
Next
WScript.Sleep 5000 This will make the script wait 5 seconds (1000=1 sec) before starting the next commands
WshShell.SendKeys "{C}" This sends a key as if you pressed it on the keyboard. In this case, you have press 'C'
WScript.Sleep 500 This will make the script wait half a second before typing the next letter
WshShell.SendKeys "{ENTER}" This presses the Enter key. (like executing the command)

Note, you can have as many WshShell.SendKeys as you want. Just add them along with the WScript.Sleep 500 command.
Note2, you can change the time delay.
Nice piece of code but Dos can not really use a vbs because they are different LANGUAGES but it can use lines of and exe, EG if you were to make a sever in C or C++ and then run the programme inside of the dos it would work as long as the C or C++ programme runs in a console window.

That is what I did for a sever I made for CSS,
Tan_ZaQuote

Nice piece of code but Dos can not really use a vbs
By using start "" filename.vbs, it runs the script outside the DOS.An alternative METHOD would be to have the script launch Fluent. Missing from the previous VBScript is grabbing a handle on the Fluent window. Consequently, the destination of the keystrokes is unpredictable.

Code: [Select]Set WshShell = CreateObject("Wscript.Shell")
WshShell.Run "Fluent.exe",,False
WScript.Sleep 100
WshShell.AppActivate "Fluent Window Title"
WScript.Sleep 100
WshShell.SendKeys "command{enter}"
WScript.Sleep 100

Just a thought. Hi, thank you all for your ideas! It turnsout it was simple, all it needed was a batch file with an indication like 'fluent -g -i start', being start' a journal file with all the inputs I wanted to give through the command line! Thank you all very much!

IsabelQuote from: IMartins on June 24, 2008, 11:17:08 AM
'fluent -g -i start'

that looks awfully like a command line switch to me....... Yes, you're right, but when I tried "fluent.exe /?" it didn't return a thing, so I thought it didn't have those capabilities, until I found a pdf that explained exactly how to do it. Thanks for your trouble!Quote from: IMartins on June 25, 2008, 04:32:10 AM
I tried "fluent.exe /?" it didn't return a thing

I'll let you off then...


Just pleased it's working now.


Discussion

No Comment Found