NAS invoks WSH batch file issue

cunnycunny Member Posts: 129
Hey guys,

I am currently working on a NAS development and the idea is to move the source files from one remote share folder to another remote share folder after they are imported into NAV. Say from \\192.168.0.23\Projects\Development\SourceFolder \\192.168.0.23\Projects\Development\BackupFolder. In NAS i created WSH automation to execute a batch file which does the job of moving files.

In order to make sure the logic is okay i run the codeunit in Navision manually and it works just fine. It does what I want nicely and every time I make sure there is no permission issue in between.

Now the problem is, NAS can import those files into NAV like what I did manually but the source files cant be moved to another backup folder.

I am just thinking maybe this has something to do with the limitation of NAS. In NAS we cant use dialog variable maybe running a *.bat file from WSH automation has the same problem coz when wsh runs the *.bat file it's using the os command line window.

Any idea?
cunny Lee
MCP - MBS Navision
jle@naviworld.com

Answers

  • cunnycunny Member Posts: 129
    ok guys,

    I think i found the trick. The problem is when I declare the automation I use the code lines like this:
    CREATE(WshShell);
    WshShell.Run(CommandLine);
    //SLEEP(2000);
    CLEAR(WshShell);
    

    And every time, NAS will clear(close) the wshshell without waiting for the automation to finish its job. That's why the job cant be done :)

    I tried two workarounds and both of them worked it out. First I tried to let NAS sleep for a while until the command line has done its job. Another idea is to simply change the way I create the automation instance, modify it like this:
    IF ISCLEAR(WshShell) THEN
    CREATE(WshShell);
    WshShell.Run(CommandLine);
    

    Now it's working fine :)
    cunny Lee
    MCP - MBS Navision
    jle@naviworld.com
  • garakgarak Member Posts: 3,263
    Follwo the link viewtopic.php?f=5&t=12417
    Do you make it right, it works too!
  • cunnycunny Member Posts: 129
    Hi garak,

    I still think it's bit tricky. After i have done a complete test on NAV DB Server which was working perfectly I migrate the same codeuite into a database hosted on SQL server 2005. Then problem comes up again.

    And I found that I have used another FILE.ERASE to get rid of the bat file after wsh is finsihed. This somehow gives a lot of trouble, it seems that when wsh is running it could not find the bat file, but i put the cleaning line after command line. When I comment the stupid file.erase line everything works fine. But then I dont have a better idea to get rid of temp bat file.

    Any idea?

    Have a nice day
    cunny Lee
    MCP - MBS Navision
    jle@naviworld.com
Sign In or Register to comment.