I want to say, the next ruby code would work better I think:

```
if datastore['REXENAME'] and datastore['REXENAME'] =~ /\.exe$/
  return datastore['REXENAME']
else
 return Rex::Text.rand_text_alpha((rand(8)+6)) + ".exe"
end
```