This code is a little difficult to read I would do something like:

```
if datastore['DELETE_FILES'] and command =~ /shell\.run \"(.*)\"/
	register_file_for_cleanup($1)
end
if command.include?(".vbs") and command.include?(",")
	# because the comma is bad character and the VBS stager contains commas it is necessary to "create" commas without directly using them
	# using the following command line trick it is possible to echo commas into the right places
	command.gsub!(",", "%i")
	command = "cmd /c FOR /F \"usebackq tokens=2 delims=)\" %i IN (\`\"ping -n 1 127.0.0.1| findstr )\"\`) DO " + command
else
	command = "cmd /c " + command
end
```

Feel free to change if it also has sense for you :)