Using "Computer name" variable in an 'exists file' construct

(imported topic written by SystemAdmin)

The IF statement in the following does not work…

if {(exists file “C:%7BComputer name%7D_HKLM.hiv”)}

delete “C:{Computer name}_HKLM.hiv”

dos reg save HKLM “C:{Computer name}_HKLM.hiv”

else

dos reg save HKLM “C:{Computer name}_HKLM.hiv”

endif

how can I embed a Computer name variable as part of a filename in an If statement?

(imported comment written by BenKus)

Since you already are evaluating relevance, no need for the brackets inside the {}…

Try this:

if {exists file (“C:” & computer name & “_HKLM.hiv”)}
delete "C:{Computer name}_HKLM.hiv"
dos reg save HKLM "C:{Computer name}_HKLM.hiv"
else
dos reg save HKLM "C:{Computer name}_HKLM.hiv"
endif

You might also just use the relevance for the Task:

exists file (“C:” & computer name & “_HKLM.hiv”)

And then you don’t need to bother with the if statement (it will only run on computers where the file exists…

Ben

(imported comment written by SystemAdmin)

Thank you Ben.