Re: On error resume next on encoded VB script
- From: Joe V <jnv0529@xxxxxxxxx>
- Date: Thu, 7 Feb 2008 14:42:50 -0800 (PST)
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?
.
- Follow-Ups:
- Re: On error resume next on encoded VB script
- From: Bob Butler
- Re: On error resume next on encoded VB script
- References:
- On error resume next on encoded VB script
- From: Joe V
- Re: On error resume next on encoded VB script
- From: Bob Butler
- On error resume next on encoded VB script
- Prev by Date: Re: On error resume next on encoded VB script
- Next by Date: Re: On error resume next on encoded VB script
- Previous by thread: Re: On error resume next on encoded VB script
- Next by thread: Re: On error resume next on encoded VB script
- Index(es):
Loading