What is 7-Zip’s command-line argument to create a self extracting archive?

I figured it out after fiddling with it:

:: zip
"C:\Program Files\7-Zip\7z.exe" a archive.exe -mmt -mx5 -sfx dirname
pause

The issue you were having is that 7-zip doesn't like spaces in the arguments. So what you wanted was something more like:

"C:\Program Files\7-Zip\7z.exe" a archive.exe -mmt -mx5 -sfx7z.sfx dirname

This should work:

"C:\Program Files\7-Zip\7z.exe" a -t7z -mx5 -sfx archive.exe directoryname -mmt

(PS: Add Program Files\7-zip to your PATH environment variable, there by you can access the file directly as 7z.exe rather than "C:\Program Files\7-Zip\7z.exe")