On error resume next on encoded VB script
- From: Joe V <jnv0529@xxxxxxxxx>
- Date: Thu, 7 Feb 2008 13:18:20 -0800 (PST)
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
End If
'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
Err.Clear
--------------------------------------------------------------------------------------------------------------
.
- Follow-Ups:
- Re: On error resume next on encoded VB script
- From: Larry Serflaten
- Re: On error resume next on encoded VB script
- From: Bob Butler
- Re: On error resume next on encoded VB script
- Prev by Date: Re: Please vote for a name
- Next by Date: Re: Please vote for a name
- Previous by thread: Paste folder from clipboard
- Next by thread: Re: On error resume next on encoded VB script
- Index(es):
Relevant Pages
|