Steps
cd $GLASSFISH/bin
asadmin create-service --name "$SERVICENAME" $DOMAIN
C:\WINDOWS\system32\sc.exe create $SERVICENAME binPath= "$glassfish-root\lib\appservService.exe \"$glassfish-root\bin\asadmin.bat start-domain --user admin --passwordfile $glassfish-root\passwordfile $DOMAIN\" \"$glassfish-root\bin\asadmin.bat stop-domain $DOMAIN\"" start=auto DisplayName="$DISPLAYNAME"
Commands (only Glassfish v3)