At first I tried this (D:\Apps\glassfish is my GLASSFISH_INSTALL directory):
D:\Apps\glassfish\lib>sc.exe create domain1 binPath="d:\Apps\glassfish\lib\appservService.exe
\"d:\Apps\glassfish\bin\asadmin.batstart-domaindomain1\"
\"d:\Apps\glassfish\bin\asadmin.bat stop-domain domain1\"" start= auto DisplayName= "SunJavaSystemAppServer DOMAIN1"
and it didn't work. Why? Look at the command that does work:
D:\Apps\glassfish\lib>sc.exe create domain1 binPath= "d:\Apps\glassfish\lib\appservService.exe
\"d:\Apps\glassfish\bin\asadmin.batstart-domaindomain1\"
\"d:\Apps\glassfish\bin\asadmin.bat stop-domain domain1\"" start= auto DisplayName= "SunJavaSystemAppServer DOMAIN1"
See the difference? No... Well, there is a space after binPath= operation. This is not the first or the second or the third, ... time I had to deal with this. And I HAVE IT ENOUGH!!!