We help IT Professionals succeed at work.

Windows password

Salim_sam asked
I need to clear - Set to blank Windows Password, in Windows 95, and 98.
Programatically - in VB.

I have downloaded this code, but don't seem to be working.

Option Explicit

     'definitions found in pwdspi.h
    Private Const PS_SYNCMASTERPWD = 3
    Private Const PS_SYNCMASTERPWD_OFF = 0
    Private Const PS_SYNCMASTERPWD_ON = 1

    Private Type CHANGEPWDINFO
       lpUserName   As String
       lpPassword   As String
       cbPassword   As Long
    End Type

    Private Const WN_OK = 0
    Private Const WN_CANCEL = 1223

    Private Declare Function PwdChangePassword Lib "mpr.dll" _
    Alias "PwdChangePasswordA" (ByVal lpProvider As String, _
    ByVal hwndOwner As Long, ByVal dwFlags As Long, _
    ByRef lpChangePwdInfo As Any) As Long

    Private Declare Function PwdSetPasswordStatus Lib "mpr.dll" _
    Alias "PwdSetPasswordStatusA" (ByVal lpProvider As String, _
    ByVal dSyncMasterPWD As Long, ByVal dSyncMasterPWD2 As Long) As Long

Public Function ChangeUserPassword(hwndOwner As Long) As Long
    'Returns 0 for success, 1223 for a user cancel, or an error code.

    Dim lngRet As Long
    Dim pwdInfo As CHANGEPWDINFO

    'Synchronize the two passwords
    lngRet = PwdSetPasswordStatus("MSNP32", PS_SYNCMASTERPWD,

    If Not (lngRet) Then
        'Call PwdChangePassword passing a null string for network provider.
        'Since Windows password is synchronized with network password, both
        'will be changed

        lngRet = PwdChangePassword(vbNullString, hwndOwner, 0, "infoline")

        'If user cancels, WN_CANCEL is returned.
        If (lngRet <> WN_OK And lngRet <> WN_CANCEL) Then
            MsgBox "PwdChangePassword failed, returning " & lngRet
            Exit Function
        End If
    End If

        ChangeUserPassword = lngRet
        Exit Function
End Function

Private Sub Command1_Click()
Call PwdChangePassword("", 0, 0, "")
End Sub

Their note:


The pwdChangePassword function actually has two declarations, depending on
the character set in use: Unicode or ASCII. The above is the ASCII
declaration. PwdChangePassword accepts the following arguments:
LpProvider-A standard Visual Basic string indicating the name of the
provider for which we are about to issue a new password. Specifying
vbNullString causes the function to operate on the logon password.
HwndOwner-The window handle of the window that will "own" the dialog. A
dialog's owner window is blocked until the dialog has been closed. Passing 0
(zero) for this argument results in a modeless dialog.
DwFlags-Specifies special behavior for the dialog; these flags are ignored
if lpProvider is a null string.
LpChangePwdInfo-A user-defined type containing the username and password.
This is actually ignored when setting the logon password.
On Windows 9x systems, there are usually two distinct passwords: the Windows
password and the logon password. Calling PwdChangePassword will change only
the user's Windows password. That's fine on a stand-alone system but could
possibly leave the logon and Windows passwords out of sync and confuse the
user of a networked system. To prevent this, we synchronize the two
passwords by calling the PwdSetPasswordStatus API function and specifying
"MSNP32" as the provider name, before calling PwdChangePassword.
PwdSetPasswordStatus is declared as follows:
Declare Function PwdSetPasswordStatus _
Lib "mpr.dll" Alias "PwdSetPasswordStatusA" _
(ByVal lpProvider As String, _
ByVal dSyncMasterPWD As Long, _
ByVal dSyncMasterPWD2 As Long) As Long

Thank you

Watch Question

IT Operations
It could be:
shell "command.com /c del c:\windows\*.pwl",vbminimized


Instead of Delete *.pwl file, Is there a another way to clear, just like first time if you leave a blank password, it doesn't prompt again.

Thank you
Richie_SimonettiIT Operations

This doesn't delete profiles, just leaves password blanks.
Just do a try:
Save your .pwl file in another place for backup
Delete .pwl
Log in and leave password blank when ask.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.