ContributionsMost RecentMost LikesSolutionsRe: Unable To Delete File After OpeningI have moved the file close out of the success loop and that seems to correct the issue. while ((!textFound)&&(i<(timeLimit*timeMultiplier))) { logFile = aqFile.OpenTextFile(fullFileName, aqFile.faRead, aqFile.ctANSI) totalLines = logFile.LinesCount; logFile.SetPosition(totalLines-lastLineOffset, columnPosition); lineText = logFile.ReadString(readStringLength); Log.Message("Text found in log file is: "+lineText); if(lineText == lineTextSearch) { textFound = true; totalLines = logFile.LinesCount; logFile.SetPosition(totalLines-lastLineOffset, columnPosition); lineText = logFile.ReadLine(); logResultObject = {textFound:textFound, lineText:lineText}; } logFile.Close(); Delay(timeDelay); i++; }Unable To Delete File After OpeningI am testing a system in a VM environment. TC resides on a Win7 VM and SUT resides across 8 VM's (some Linux, some Server 2003) in this environment. As part of testing, I prepare the test data in JADE and Oracle databases. This involves executing some JADE code on an application server which then calls Java code. This code can either "Validate" the data input files (CSV files), "Delete" or "Update" data in the databases. The Delete/Update process first delete/add data to/from the JADE system which then triggers the process to delete/add data to/from the Oracle database. As part of the routines, log files are produced that contains information about the process progress and state. I monitor the Jade log file to determine when the process is complete. An entry is made when the process starts, when the task is passed to the Java process and then return codes when the Java process is completed, which indicates that the entire process is completed. The process I follow is to Delete to test data followed by Update to add test data. The process I follow is: 1. Delete log files 2. Delete test data a) trigger task b) monitor Jade log file 3. Copy log file to result directory on TC VM 4. Delete log files 5. Update test data a) trigger task b) monitor Jade log file 6. Copy log file to result directory on TC VM The problem I have is that I am unable to "Delete log files" in step 4 as the file is being used by another process. When I add a break point in the code that performs the delete, I attempt to delete the file manually (via command line) I get the same message. Only when I stop the TC test run am I able to delete the log file. I suspect the issue is when I open the file to read the contents, and when I find the content I am looking for, I close the file, however TC does not release the handle on the log file until the test run is completed. Can you assist with the problem? CODE SNIPPET - to examine log file while ((!textFound)&&(i<(timeLimit*timeMultiplier))) { logFile = aqFile.OpenTextFile(fullFileName, aqFile.faRead, aqFile.ctANSI) totalLines = logFile.LinesCount; logFile.SetPosition(totalLines-lastLineOffset, columnPosition); lineText = logFile.ReadString(readStringLength); if(lineText == lineTextSearch) { textFound = true; totalLines = logFile.LinesCount; logFile.SetPosition(totalLines-lastLineOffset, columnPosition); lineText = logFile.ReadLine(); logResultObject = {textFound:textFound, lineText:lineText}; logFile.Close(); } Delay(timeDelay); i++; } CODE SNIPPET - to delete log file while ((!successFlag) && (i < failAttempt)) { //successFlag = aqFile.Delete(fullFileName); successFlag = aqFileSystem.DeleteFile(fullFileName); i++ Delay(timeDelay); } Re: Query Schedule Task On Remote Virtual MachineHello Martin Have you been able to give this query any further thought? Regards MarkRe: Query Schedule Task On Remote Virtual MachineHello Martin When I say it is not working, I mean the expected csv file is not generated. The command is executing, as I can see the command window open and close, however the CSV file containing the information is not created. If I copy the string directly into a command window it does work. I get the string by copying it from the Debug/Evaluate dialog. Regards Mark Re: Query Schedule Task On Remote Virtual MachineHello Robert, I tried using the same method as suggested for my earlier post, however it was not successful. cmdString = "SCHTASKS /Query /S "+remoteServer+" /U "+userName+" /P "+passWord+" /FO CSV >> "+fileName; shellObject = Sys.OleObject("WScript.Shell") execOut = shellObject.Exec(cmdString) I can use the very same string on a command line and that works, however via TC script I am not having any luck. Regards MarkRe: Time Sync Machine inside VM EnvironementHello Robert Thank you for the advice, it works. Regards MarkQuery Schedule Task On Remote Virtual MachineWe have a testing environment which comprises a number of VM's that represent our production system. TestComplete resides on its own XP VM in this environment, however is part of a Workgroup and is not on the Domain with the VM's that make up the system. What I am trying to do is check if a Schedule Task exists on one of the remote VM's in the environment. I am trying to achieve this by doing the following: [JScript] var remoteServer = "\\\\AMIPSP01" var userName = "user"; var passWord = "password"; var computerName = aqEnvironment.GetEnvironmentVariable("COMPUTERNAME"); var tempPath = aqEnvironment.GetEnvironmentVariable("TEMP"); var fullTempPath = LongPathName(tempPath); //function to convert the short path name to a long path name var tempDir = aqString.Replace(fullTempPath, ":","$"); var fileName = "\\\\"+computerName+"\\"+tempDir+"\\SchduleTaskList.csv"; var cmdString = "SCHTASKS /Query /S "+remoteServer+" /U "+userName+" /P "+passWord+" /FO CSV >> "+fileName; var processID = WMI.CreateProcess(cmdString); I ave tried this script an a number of variations, however have not been able to generate a file listing the scheduled tasks. Your help will be appreciated. Regards Mark Time Sync Machine inside VM EnvironementWe have a testing environment which comprises a number of VM's that represent our production system. TestComplete resides on its own XP VM in this environment, however is part of a Workgroup and is not on the Domain with the VM's that make up the system. What I am trying to do is ensure the TC VM is time synchronised with the Comms VM and I do this each time the project suite is executed. I amtrying to achieve this by doing the following: [JScript] var commsServerName = "\\\\AMICOMMS01"; var cmdString = "net time "+commsServerName+" /set /y"; var processID = WMI.CreateProcess(cmdString); I have not success in synchronising the TC VM with the Comms VM using the snippet above. I do however have success when from the TC VM command line or Run line use "net time \\AMICOMMS01 /set /y" Do you have any suggestion/s? Regards Mark Re: Does Folder ExistsThank you Allen you suggestion did the job. I originally tried the method located at http://smartbear.com/support/viewarticle/13654/ which is what I quoted in my initial post. this method appears not to work. Also their is a typo on the page "Exmaple" should read "Example" Cheers MarkDoes Folder ExistsI am attempting to check if a folder exists and if it does not the create. checkLocation = "C:\\Documents and Settings\\user\\Local Settings\\Temp\\TestComplete\\"; //Check if the location exists if (!aqFileSystem.GetFolderInfo(checkLocation).Exists) { // Creates the folder createSuccess = aqFileSystem.CreateFolder(checkLocation); } The 'TestComplete" sub folder does not exist and I expect to get a result of false. However, when evaluating the expession 'aqFileSystem.GetFolderInfo(checkLocation).Exists' I get "Unable to open the folder." and thus an exception. when altering checkLocation variable to 'checkLocation = "C:\\Documents and Settings\\user\\Local Settings\\Temp\\";' the expression evaluates as true. Can you offer a solution to checking if the folder exists? Thanks Mark