SHELLing a Sequence of commands from NF

How can I SHELL the following sequence of commands from Navision : CMD CD C:\ DIR > DIR.TXT EXIT I could the have these 4 commands in a batch file (.BAT) and simply have SHELL(‘MyBatchFile.BAT’); But I want to avoid this … Any suggestions ??? tarek_demiati@ureach.com

CMD DIR C:\ > C:\DIR.TXT Business Applications Programmer Sertified Navision Developer SIA “Sintegra” Latvia

I’ve just tried : SHELL(‘CMD DIR C:\ > C:\DIR.TXT’); and it does not work on my Win 2000 Professional box It just starts a command line session and do not create a DIR.TXT file on my C:/ drive. BTW I also needs to close this command line window once I’ve done my bits … tarek_demiati@ureach.com

Win2000 has an emulation of command shell and some of the features available at Win95/98 are just removed there. So the best possible solution will be to create a batch file and execute it. If you dont the batch file to stay on the disk you can create,execute and delete it dynamically in Navision. Just an idea :slight_smile:

I have tried this on w98: SHELL(‘c:\command.com’,’/c’,‘dir c:*.* >d.txt’); runs fine.

phew…it seems that the lunch time has come…I am eating some words. I meant “If you dont want the batch file…” :slight_smile:

Do like this retval:=shell(‘cmd.exe’,’/c’,‘dir >c:\dir.txt’); Regards

You need get environment’s variable “ComSpec” to get current DOS command interpreter’s command. Use: ComSpecStr := ENVIRON(‘ComSpec’). //… //… //… This variable exists in all Win. Business Applications Programmer Sertified Navision Developer SIA “Sintegra” Latvia

quote:


retval:=shell(‘cmd.exe’,‘/c’,‘dir >c:\dir.txt’);


This works with win2000 Regards Vishal

quote:


How can I SHELL the following sequence of commands from Navision : CMD CD C:\ DIR > DIR.TXT EXIT


What do you want to reach with that? Do you need to process files within Navision? If yes, there’s a better possibility at hand: Example: Read all Files *.TXT from directory C:\Interface\


Var
  recFile : Record (File)

WITH recFile DO BEGIN
  SETRANGE("Is a file",TRUE);
  SETRANGE(Path,'');
  IF FIND('-') THEN;
  SETRANGE(Path,'C:\Interface\");
  recFile.SETFILTER(Name,'*.TXT');
  IF FIND('-') THEN REPEAT
    Message ('Processing File %1',Name);
  UNTIL
 

------- With best regards from Switzerland Marcus Fabian Edited by - fabian on 2001 Jul 04 23:11:05