Forums

 
HomeHomeRoyal TS V 1.xRoyal TS V 1.xToolboxToolboxUnlock AD account using taskUnlock AD account using task
Previous
 
Next
New Post
9/22/2009 10:23 AM
 

Hi

I managed to create a task that unlock an Active directory account. The problem is that I have to edit the command to type the username that I want to unlock. Is there a way to be prompted for the username ?

My taks is defined the following way :

Command : psexec.exe

Argument : \\$Host$ net.exe user Username /active:yes

Working Directory : %systemroot%

 
New Post
9/23/2009 7:56 AM
 

Ok, I figure it out.

Following what I started yesterday I made a small bat file called "UnlockRTS.bat" to do the trick.

@echo off
echo "Enter Username"
set /p UserName=
psexec.exe \\%1 net.exe user %UserName% /active:yes
Pause
Exit

Then I defined a task in Royal TS

Command : UnlockRTS.bat

Argument : $Host$

Working Directory : %systemroot%

 

The same way, I made another bat file to reset password :

@echo off
echo "Enter Username"
set /p UserName=
echo "Enter New Password 1st time"
set /p Password1=
echo "Enter New Password 2nd time"
set /p Password2=
if %Password1%==%Password2% goto CHG
if not %Password1%==%Password2% goto ERR
:CHG
psexec.exe \\%1 net.exe user %UserName% %Password1%
Pause
Exit
:ERR
echo "Password1 is not the same as Password2. Please restart"
Pause
Exit

 

Remark :

- These BAT files requires psexec.exe (the link to download it can be found somewhere else on this forum).

- In my case, these BAT files are saved in folder C:\WINDOWS\system32

 
New Post
9/23/2009 7:47 PM
 

Hi Dennis,

thanks for sharing your solution!

If you want to get rid of the batch file you could have a look at the blog post I wrote a long time ago: http://code4ward.net/main/Blog/tabid/70/EntryId/7/MOM-Tasks-Commands-and-Magic.aspx

It basically shows how to do all that in a one-liner. I'm not sure if your batch file can be 'converted' but it's worth a look...

cheers,

Stefan


Stay in touch with code4ward.net:

Subscribe to our Blog RSS FeedFollow us on TwitterLike us on FacebookOur Google+ page
 
Previous
 
Next
HomeHomeRoyal TS V 1.xRoyal TS V 1.xToolboxToolboxUnlock AD account using taskUnlock AD account using task


spacer
dummy