Re: On error resume next on encoded VB script
- From: "Bob Butler" <noway@xxxxxxxxxxx>
- Date: Thu, 7 Feb 2008 13:55:15 -0800
"Joe V" <jnv0529@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
.
- Follow-Ups:
- Re: On error resume next on encoded VB script
- From: Joe V
- Re: On error resume next on encoded VB script
- From: Richard Mueller [MVP]
- Re: On error resume next on encoded VB script
- References:
- On error resume next on encoded VB script
- From: Joe V
- On error resume next on encoded VB script
- Prev by Date: Re: How to retrieve IP address using VB6?
- Next by Date: Re: showing code in vb2005
- Previous by thread: On error resume next on encoded VB script
- Next by thread: Re: On error resume next on encoded VB script
- Index(es):
Relevant Pages
|