web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics GP (Archived)

Can you execute DOS commands from within a sanScript procedure

(1) ShareShare
ReportReport
Posted on by 6

We have a routine that builds a HTML file to send to a user.  I do this by writing the text file to a directory and then sending the file via email.

What I want to do is delete the file again at the end of the the process. 

Dexterity has Text_FileOpen and Text_FileClose commands to open and close a file, but no command to delete a file.  I thought I may be able to use the DOS del command but I can't get that to work either.

Any ideas?  The only other thing I can think to do is to write little application in .NET to do the file delete and call that using the "run application" command within SanScript.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    MG-16101311-0 Profile Picture
    26,225 on at

    Dexterity also provides the File_Delete() function. Just pass in the full path and name of the file in generic format, for example:

    local string filePath = "C:\SomeFolder\SomeFile.txt";
    local boolean result;
    
    filePath = Path_MakeGeneric(filePath);
    result = File_Delete(filePath);
  • MG-16101311-0 Profile Picture
    26,225 on at

    By the way, you can run a DOS command from Dexterity too:

    local string cmdPath = "C:\Windows\SysWOW64\cmd.exe";
    local string cmdParams = "/c dir C:\Temp\*.*";
    
    run application cmdPath, cmdParams;


    If you want to keep the command shell window open, just use /k instead of /c.

  • mavrick5au Profile Picture
    6 on at

    Thanks Mariano.  That solves my problem.  Has this command always been there or only in the more recent versions of Dex?

  • MG-16101311-0 Profile Picture
    26,225 on at

    It's always been there -- or less put it this way, as far back as I can remember :-)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics GP (Archived)

#1
Community Member Profile Picture

Community Member 2

#2
mtabor Profile Picture

mtabor 1

#2
Victoria Yudin Profile Picture

Victoria Yudin 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans