Re: On error resume next on encoded VB script



On Feb 7, 4:55 pm, "Bob Butler" <no...@xxxxxxxxxxx> wrote:
"Joe V" <jnv0...@xxxxxxxxx> wrote in message

news:aeddbc5a-f033-49e6-b34a-47b3cad69226@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx





Hello,

I have a vb script that changes the local admin password of a
machine.  My company has offices in U.S. and Canada so we have two
different usernames for the local admin account, one in English one in
French depending on where you are located.  My script tries to change
the password for both.  I have it set to resume if there is an error
since only one of the usernames will actually work.  The program works
fine as a vbscript but after using the Windows Script Encoder it fails
if the first username that it tries to change doesn't exist.  No I
can't have just one username, we have to have one in English and
French.

Here is the code (the only thing I changed was the actuall password
and usernames:
---------------------------------------------------------------------------­---------------
Set WshNetwork = WScript.CreateObject("WScript.Network")
strComputer = WshNetwork.ComputerName
strPSWD = "Password"

'If username does not exist ignore error
On Error Resume Next

'Change password for French local admin account
Set objUser = GetObject("WinNT://" & strComputer & "/Frenchname,user")
If Err.Number = 0 Then
 objUser.SetPassword strPSWD
 objUser.SetInfo

Else
  Err.Clear

'Change password for English local admin account
Set objUser = GetObject("WinNT://" & strComputer & "/
Englishname,user")
If Err.Number = 0 Then
 objUser.SetPassword strPSWD
 objUser.SetInfo
End If

End If- Hide quoted text -

- Show quoted text -

So I put
"Else
Err.Clear"

After each If statement rather than only at the end?
.


Loading