Geeks With Blogs

Soppa Group India
iSmart Panache Inc
R Systems Internationals Ltd
Technovate eSolutions Pvt Ltd
The contents of this blog are my personal opinion and do not represent in any way the view of my employer.
These postings are provided "AS IS" with no warranties, and confer no rights.

Google PR™ - Post your Page Rank with

Narendra Tiwari

It has really been a head scratching task for me. I 've tried many options but nothing worked. Finally I found a workaround on google to achive this by TaskScheduler.

When we run Teamsite user administration command line tool IWUSERADM.exe though ASP.Net it gives following error:

Application popup: cmd.exe - Application Error : The application failed to initialize properly (0xc0000142). Click on OK to terminate the application.

No specific cause, it seems to be a bug, supposed to be resolved with this Microsoft patch, Moreover there is nothing related to permission issue my web application is impersonated with an administrator account. offcourse running a .bat file from admin account is a potential security threat but for this scenario lets conifne our discussion to run the command line tool only.

I have not tried this patch as I have not permitted to run this patch on server. Below are the steps to achive the requirement.

1/ Create a batch file which runs the IWUSERADM.exe. 
       echo - Add Teamsite User
   CD E:\Appli\GN00\iw-home\bin
   iwuseradm add-user %1

2/ Temporarily create a schedule task and run  the .bat file by scheduled task by ASP.Net code using TaskScheduler

3/ Here is the function:
private int AddTeamsiteUser(string strBatchFilePath, string strUser)
//Get a ScheduledTasks object for the local computer.
ScheduledTasks st = new ScheduledTasks();
// Create a task
Task t;
t = st.CreateTask("~AddTeamsiteUser");
throw new Exception("Schedule Task ~AddTeamsiteUser already exist.");

t.ApplicationName = strBatchFilePath;
t.Parameters = strUser;
t.Comment = "Adding user to Teamsite Application"

t.SetAccountInformation(yourLogin, yourPassword); 

Thread.Sleep(2000); //for sync issue 

//Remove the scheduled task

return t.ExitCode;

Calling function
//Add User in Teamsite
string strBatFilePath = ConfigurationManager.AppSettings["batFilePath"];
this.AddTeamsiteUser(strBatFilePath, domainName\UserName)

Below are few resources related to the above scenario:-
- Task Scheduler Class Library for .NET
- Run a .BAT file from ASP.NET
- TaskScheduler Class
- Application Hangs whle running iwuseradm.exe through ASP.Net


Posted on Thursday, May 27, 2010 10:33 AM .Net | Back to top

Comments on this post: Running Teamsite User Admin tool IWUSERADM.exe from ASP.NET

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © Narendra Tiwari | Powered by: