Webmaster Forum

Go Back   Webmaster Forum > Scripting/Programming & Debugging > ASP & VBScript Forum
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

ASP & VBScript Forum Need help from a webmaster with ASP or VBScript, you may ask in this forum?

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-13-2007, 08:06 AM
Meic Meic is offline
Junior Member
 
Join Date: Dec 2007
Posts: 1
Meic is an unknown quantity at this point
Submit to Clesto Submit to Digg Submit to Reddit Submit to Furl Submit to Del.icio.us Submit to Jeqq Submit to Spurl
Default Script not completing

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.
Reply With Quote

This ad is part of our Revenue Sharing program
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 06:15 AM.


Creative Commons License
Powered by vBulletin Version 3.6.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.0.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30