def create_desktop(desktop_name, start_explorer=1):
 sa = pywintypes.SECURITY_ATTRIBUTES()
 sa.bInheritHandle = 1
 try:
  hdesk = win32service.CreateDesktop(desktop_name, 0, win32con.MAXIMUM_ALLOWED, sa)
 except win32service.error:
  traceback.print_exc()
  errbuf = cStringIO.StringIO()
  traceback.print_exc(None, errbuf)
  win32api.MessageBox(0, errbuf.getvalue(), 'Desktop creation failed')
  return
 if start_explorer:
  s = win32process.STARTUPINFO()
  s.lpDesktop = desktop_name
  prc_info = win32process.CreateProcess(None, 'Explorer.exe', None, None, True, win32con.CREATE_NEW_CONSOLE, None, 'c:\\', s)
 th = thread.start_new_thread(new_icon, (hdesk, desktop_name))
 hdesk.SwitchDesktop()

def create_desktop ( desktop_name , start_explorer = 1 ) : sa = pywintypes . SECURITY_ATTRIBUTES ( ) sa . bInheritHandle = 1 try : hdesk = win32service . CreateDesktop ( desktop_name , 0 , win32con . MAXIMUM_ALLOWED , sa ) except win32service . error : traceback . print_exc ( ) errbuf = cStringIO . StringIO ( ) traceback . print_exc ( None , errbuf ) win32api . MessageBox ( 0 , errbuf . getvalue ( ) , 'Desktop creation failed' ) return if start_explorer : s = win32process . STARTUPINFO ( ) s . lpDesktop = desktop_name prc_info = win32process . CreateProcess ( None , 'Explorer.exe' , None , None , True , win32con . CREATE_NEW_CONSOLE , None , 'c:\\' , s ) th = thread . start_new_thread ( new_icon , ( hdesk , desktop_name ) ) hdesk . SwitchDesktop ( )
creates a new desktop and spawns a thread running on it will also start a new icon thread on an existing desktop .