How can I turn on File and Printer sharing, and the Firewall from the Windows command line
This command should take care of the File and Printer Sharing:
netsh advfirewall firewall set rule group="File and Printer Sharing" new enable=Yes
For the firewall:
netsh advfirewall set currentprofile state on
I've tried them just now, and its seems to work for me.
For any additional information see Microsofts KB article: http://support.microsoft.com/kb/947709