NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

delete a file..

Solved!
Go to solution

Hi,

 

I am failing to use a Call Executable step to run command line string to delete the file.

 

The file I want to delete is debug.txt in C:\Python_Code\4Simon\dist.

 

I can manage to run a exe file using Call Executable step but when it comes to DOS commands, failed.

 

Can any point me in the right direction, Please.

 

I have XP and TS 2012

 

Thanks

Simon  

0 Kudos
Message 1 of 8
(5,360 Views)
Solution
Accepted by topic author Srm27

Use the following in argument expression

 

"cmd /c del C:\\Python_Code\\4Simon\\dist\\debug.txt"


CLA CTAChampionI'm attending the GLA Summit!
Subscribe to the Test Automation user group: UK Test Automation Group
Message 2 of 8
(5,353 Views)

Hi,

 

Thanks for that, it works.

 

Opens the door to a few more options.

 

Thanks

Simon

0 Kudos
Message 3 of 8
(5,330 Views)

 

Hi,

 

Sorry to come back to this but I am unable to delete an xml file using this method.

 

On running TS for the first time the xml file will be deleted.

 

Next step is CVI code to read a hardware configuration using TFTP and the result is stored in the xml file.

 

Still within the CVI code I open the xml file, extract the information, display it and then close the file, no problems.

 

The TS sequence finishes and all comes to an end.

 

When I go to run the sequence again the xml will not be deleted, it is been held by TS in some way preventing it from been deleted.

 

Any idea as to what I am doing wrong?

 

Thanks

Simon

0 Kudos
Message 4 of 8
(5,264 Views)

To ascertain that TS is holding your file, add a statement (very last step in cleanup) with the following expression:

 

Runstate.Engine.UnloadAllModules()

 

If you are able to delete the file during the next run you can be sure that TS is holding the file. This may be because you are not releasing the file reference properly or something to do with your CVI code. This will need further investigation. You could set a breakpoint in your CVI code after you have closed your file handle and try deleting it manually to ensure you can do it.

 

Hope this helps.


CLA CTAChampionI'm attending the GLA Summit!
Subscribe to the Test Automation user group: UK Test Automation Group
0 Kudos
Message 5 of 8
(5,260 Views)

Hi,

 

Added in as requested, still unable to delete the file.

 

Put a breakpoint in the CVI code after the close file, still unable to delete the file.

 

The only times I can delete the file is the first time into TS or when TS is closed and so CVI is also closed, as I am using ddl call from TS.

 

Thanks

Simon

 

 

0 Kudos
Message 6 of 8
(5,254 Views)

Is TestStand opening the file for any reason? If not, it is most likely not TestStand holding on to the file. More likely it is either your code not closing the file for every place it was opened, or some other program you might be using which is accessing the file and hasn't closed it yet. Are you perhaps opening the file more than once? Is the CloseHandle call on the file handle succeding (check the return value)? Is it the right close function for the open function you are using? Is there perhaps other code you are running from teststand that might be keeping the file open?

 

-Doug

0 Kudos
Message 7 of 8
(5,248 Views)

 

Hi,

 

I should count a bit better/look harder think smarter, yes I did miss the close in the CVI code.

 

Thanks for the help.

 

Simon

0 Kudos
Message 8 of 8
(5,243 Views)