Skip to main content

Notifications

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

  • Mariano Gomez Profile Picture
    26,225 on at
    RE: Can you execute DOS commands from within a sanScript procedure

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

  • mavrick5au Profile Picture
    6 on at
    RE: Can you execute DOS commands from within a sanScript procedure

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

  • Mariano Gomez Profile Picture
    26,225 on at
    RE: Can you execute DOS commands from within a sanScript procedure

    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.

  • Verified answer
    Mariano Gomez Profile Picture
    26,225 on at
    RE: Can you execute DOS commands from within a sanScript procedure

    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);

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,206 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,968 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans