![]() |
|
|||||||
| ASP & VBScript Forum Need help from a webmaster with ASP or VBScript, you may ask in this forum? |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Hi,
I have the following code, where user gets added to local domain admin if required. If there are errors i.e. User already local admin, or user not on domain, I need it to display the relevant error message (this bit works). If there are no errors, I just want it to run the bottom line i.e. oShell.Run "C:\Progra~1\applayer\App2.lnk". The problem I'm having is that the script doesn't run the bottom 2 lines, if there are no errors it just quits. Can anyone see where I'm going wrong? On error resume next Set oShell = CreateObject("WScript.Shell") strComputer = "." Set objArgs = WScript.Arguments Set objGroup = GetObject("WinNT://" & strComputer & "/Administrators") Set objUser = GetObject("WinNT://domain/" & objArgs(0)) objGroup.Add(objUser.ADsPath) If Err.Number <> 0 Then If Hex(Err.Number) = "80070562" Then MsgBox "Username already added - Re enter Username" Else MsgBox "User not on Domain - Re enter Username" End If oShell.Run "C:\Progra~1\UserForm\ver1c\WinApp1.exe" End if 'If no errors I want it to run following msgbox "done." oShell.Run "C:\Progra~1\applayer\App2.lnk" I would just like to add that I have tried the following code: If Hex(Err.Number) = "80070562" Then MsgBox "Username already added - Re enter Username" oShell.Run "C:\Progra~1\UserForm\ver1c\WinApp1.exe" End If If Hex(Err.Number) = "80070035" Then MsgBox "User not on Domain - Re enter Username" oShell.Run "C:\Progra~1\UserForm\ver1c\WinApp1.exe" End If 'If no errors I want it to run following msgbox "done." oShell.Run "C:\Progra~1\applayer\App2.lnk" But for some reason, the script doesn't pick up error code "80070035" (as a test, I just had that error number checked - still doesn't do it). That is why I have the script the way it is. Thanks. |
|
This ad is part of our Revenue Sharing program |