georgereynolds
9 years agoOccasional Contributor
aqEnvironment.GetEnvironmentVariable fail
I have a script which uses the following line
HOMEPATH = aqEnvironment.GetEnvironmentVariable("HOMEPATH")
This fails the script (i.e. the files do not get deleted as they should per the script).
I will add that this works fine in Testcomplete12 on my desktop - but on the server running TestExecute12 it fails and it outputs the Log.Error message
If I replace it with the hardcoded path, it works
HOMEPATH = "C:\users\builduser\"
Full script is below - any suggestions why this occurs?
Sub DeletePDFFiles ms = 5000 HelpStr = "Delaying script for " & ms & "milliseconds." aqUtils.Delay ms, HelpStr Dim spath, spath2, HOMEPATH HOMEPATH = aqEnvironment.GetEnvironmentVariable("HOMEPATH") sPath1 = HOMEPATH & "\Downloads\ClaimForm*" sPath2 = HOMEPATH & "\Downloads\xxx_UK_xx_xx_xx_T_And_C_2016*" cPath1 = HOMEPATH & "\Downloads\ClaimForm.pdf" cPath2 = HOMEPATH & "\Downloads\xxx_UK_xx_xx_xx_T_And_C_2016.pdf" If aqFileSystem.Exists(cPath1) Then Log.Message "Claim Form Doc Found!" aqFileSystem.DeleteFile(sPath1)
If Not aqFileSystem.Exists(cPath1) Then Log.Message "ClaimForm Doc Deleted" Else Log.Error "ClaimForm NOT Deleted" End if Else Log.Error "Claim Form Doc NOT Found!" End if If aqFileSystem.Exists(cPath2) Then Log.Message "T&C Doc Found!" aqFileSystem.DeleteFile(sPath2) If Not aqFileSystem.Exists(sPath2) Then Log.Message "T&C Doc Deleted" Else Log.Error "T&C Doc NOT Deleted" End if Else Log.Error "T&C Doc NOT Found!" End if End Sub
I've fixed this as I echoed HOMEPATH and realised it didn't include "C:\" (it was just "users\builduser\") so I added that in and it works now!