def create_task(name, location='\\', user_name='System', password=None, force=False, **kwargs):
 if ((name in list_tasks(location)) and (not force)):
  return '{0} already exists'.format(name)
 pythoncom.CoInitialize()
 task_service = win32com.client.Dispatch('Schedule.Service')
 task_service.Connect()
 task_definition = task_service.NewTask(0)
 edit_task(task_definition=task_definition, user_name=user_name, password=password, **kwargs)
 add_action(task_definition=task_definition, **kwargs)
 add_trigger(task_definition=task_definition, **kwargs)
 task_folder = task_service.GetFolder(location)
 _save_task_definition(name=name, task_folder=task_folder, task_definition=task_definition, user_name=task_definition.Principal.UserID, password=password, logon_type=task_definition.Principal.LogonType)
 if (name in list_tasks(location)):
  return True
 else:
  return False

def create_task ( name , location = '\\' , user_name = 'System' , password = None , force = False , ** kwargs ) : if ( ( name in list_tasks ( location ) ) and ( not force ) ) : return '{0} already exists' . format ( name ) pythoncom . CoInitialize ( ) task_service = win32com . client . Dispatch ( 'Schedule.Service' ) task_service . Connect ( ) task_definition = task_service . NewTask ( 0 ) edit_task ( task_definition = task_definition , user_name = user_name , password = password , ** kwargs ) add_action ( task_definition = task_definition , ** kwargs ) add_trigger ( task_definition = task_definition , ** kwargs ) task_folder = task_service . GetFolder ( location ) _save_task_definition ( name = name , task_folder = task_folder , task_definition = task_definition , user_name = task_definition . Principal . UserID , password = password , logon_type = task_definition . Principal . LogonType ) if ( name in list_tasks ( location ) ) : return True else : return False
create a new task in the designated location .