I’m new to VBS and I’m attempting to make a start on a UAC in Windows – A will to do and in turn, learn.
I don’t understand why I keep getting a syntax error on the line before the last End If
If you could help, I’d be greatly appreciative!
CurPass = ReadIni("C:\Program Files\User Account Control\ident.ini", "pass", "pass")
InpPass = inputbox("Please enter your current password:")
If InpPass = CurPass Then
NewPass = inputbox("Please enter your new password")
if NewPass=CurPass Then
KpPass=msgbox("Your new password is the same as your old password. Keep old password?",4+32,"UAC")
if KpPass=7 Then MsgBox("Please try again")
end if
Else
RNewPass = inputbox("Please re-enter your new password")
end if
if RNewPass=NewPass then
WriteIni "C:\Program Files\User Account Control\ident.ini", "pass", "Pass", NewPass
else msgbox("Your new passwords do not match. Try again.")
end If
else msgbox("Incorrect password")
End if
There is no If .. Then for your last Else .. End If. This would be obvious immediately, if you had used proper indentation.
Update: Above diagnosis is wrong.
I think you want this structure:
Then VBScript lost its way when you wrote:
You can have ‘short ifs’ like
but then there should be no
End If. It’s a bit like omitting {} for single line/statement conditionals in other C alike languages. That is: better avoided.