send .bat file to network barcode printer

yvonne
yvonne Member Posts: 31
:? I failed to print barcode from workstation (navision3.7) to barcode printer which attached with server.

I generate my .bat file at my c: drive though below coding --
Test.CREATE('C:\BatchName.bat');
Test.write('xxxx')
Test.Close

The barcode can print out through command prompt--
C:\>copy batchName.bat \\172.28.7.246\SATO

But it can't print from Nav, please point out my mistake -- :oops:
SHELL('copy', 'C:\BatchName.bat', '\\172.28.7.246\SATO');

Error Prompt: Operating System cannot find the file copy.

please help..
:|

Comments

  • Poltergeist
    Poltergeist Member Posts: 200
    Copy is an internal command from the commandshell. So you need to start the commandshell (on NT systems cmd.exe, on 9x systems command.exe). The proper line would be something like
    SHELL(environ(comspec), '/c copy C:\BatchName.bat \\172.28.7.246\SATO');
  • yvonne
    yvonne Member Posts: 31
    :D It work. Thank you very much, Poltergeist.
  • marina_ee
    marina_ee Member Posts: 30
    i am facing same problem for FTP.

    this command

    SHELL('ftp','-s:' + FTPScriptFName, FTPServer);

    it says "operating system cannot find the file ftp.

    so i changed to

    SHELL(ENVIRON('comspec'), 'ftp' + ' ' + '-s:' + FTPScriptFName + ' ' + FTPServer

    but the command prompt screen came out with this path

    C:\Program Files\ Microsoft business Solution-Navision\Client>

    then stopped there waiting for me to type command.

    1. I am sure FTPScriptFName and FTPServer values are valid
    2. I am sure there are FTP.exe in my PC because I can run FTP command from DOS
  • Poltergeist
    Poltergeist Member Posts: 200
    After the Environ('comspec'), you need to use a /c, to indicate the command to be started, and that the window has to close when it's ready. If you do not use /c, the command shell is started, but nothing will happen (like what's happening now)

    your command should be:
    SHELL(ENVIRON('comspec'), ' /c ftp' + ' ' + '-s:' + FTPScriptFName + ' ' + FTPServer

    FTP.EXE is indeed on your PC, so there should be no need to start the command shell. Usually, FTP.EXE is in ENVIRON('SYSTEM ROOT')+'\system32'. You should be able to run the program with
    SHELL(ENVIRON('SYSTEM ROOT'')+'\system32\FTP.EXE','+'-s:' + FTPScriptFName + ' ' + FTPServer'. Haven't tried that myself, though.
  • marina_ee
    marina_ee Member Posts: 30
    i added /c and the screen close almost immediately, the script was wrong, but I was not able to see the error message. Any idea to pause the screen?
  • Poltergeist
    Poltergeist Member Posts: 200
    Use /k instead of /c. The program will start, but when it's finished, the command shell is not closed.
  • marina_ee
    marina_ee Member Posts: 30
    1. the error was "cannot open the script file" because after the shell command, it continues the next statement to delete the script file (the script file was meant to be deleted after the ftp process). i need a way to make the ftp process "modal", so that the program delete statement only run after the DOS screen closes.

    2. any other switch (like /k, /s) to let the user to see the process and at the end prompt "press any key to continue..."
  • Poltergeist
    Poltergeist Member Posts: 200
    I believe the shell command has an option to run modal...

    Or use something like

    SHELL(ENVIRON('comspec'), chr(34)+'ftp' + ' ' + '-s:' + FTPScriptFName + ' ' + FTPServer'+chr(34)+"&&"+chr(34)+"del FTPScriptname"

    Then the DEL command is operated after the the FTP command. Use && to execute multiple commands.
  • marina_ee
    marina_ee Member Posts: 30
    Dear Poltergeist, thanks for reminding me, the shell command has the option to run modally... i check out the help, just need to assign the shell command to a return code.

    and I put "PAUSE" as the subsequent command for "press any key to continue..."

    thanks again, now I can sleep tonite. =D>