Click here to Skip to main content
15,911,711 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hello,

I tried to create a small application using vb.net which has a button and textbox.

User inputs new password to which is to be set as new password in the text box and click on the button does the following :
VB
Shell("net user administrator *")
Thread.Sleep(3000)
AppActivate(Application.StartupPath & "\Simple WinHack.vshost.exe")
SendKeys.SendWait(TextBox1.Text)
SendKeys.SendWait("{ENTER}")
SendKeys.SendWait(TextBox1.Text)
SendKeys.SendWait("{ENTER}")
MsgBox("Windows Password has beeen removed successfully.", MsgBoxStyle.Information)


After executing Shell("net user administrator *"), It opens CMD and asks for new password and repeat password, I input that using SendKeys.

But, Somewhat doesn't work, MessageBox appears and Execution ends but password not changed.
Posted

1 solution

The account this code is running under must have permissions to change the password.

This is also the worst way to change a password. Using WMI or the Win32 API is far more appropriate and you have much greater control.
 
Share this answer
 
Comments
jenitshah 27-Oct-13 23:21pm    
Account is having permissions. Also When I try with only Sending {ENTER}s twice, I am getting reset the password, problem only occurs while I try sending string.

Win32 API function requires old / current password, This one doesnt require.
Dave Kreskowiak 28-Oct-13 7:24am    
If you mean the NetUserChangePassword function, yes it does. It's the function that's called by the Change Password lock screen option.

But, NetUserSetInfo[^] doesn't need the previous password. You just need to pass in a USER_INFO_1003 structure with the new password in it.
jenitshah 28-Oct-13 8:48am    
Finally, I done it. Only problem was the window was not focused even after "AppActive(..", After I set AppWinStyle to NormalFocus It works perfectly. Thanks.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900