Page 1 of 1 1
Topic Options
#154479 - 2006-01-03 05:14 AM Error handling in ADSI
20thCenturyBoy Offline
Lurker

Registered: 2005-12-04
Posts: 4
Hi all, I am using the following code to create a Windows share on a remote server:
Code:

$oServer = GetObject("WinNT://MyDomain/" + $FileServer + "/LanmanServer")
$oShare = $oServer.Create("fileshare", $UserName + "$")
$oShare.Path = "D:\Users\" + $UserName
$oShare.MaxUserCount = -1 ; unlmited users
$oShare.SetInfo



which works admirably, but how do I detect an error if the share already exists or some other error occurs? In VBscript there is an Err object which can be queried after the SetInfo() call. Is there a similar thing for Kix, or can I access the Err object?

Top
#154480 - 2006-01-03 05:30 AM Re: Error handling in ADSI
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11628
Loc: CA
$oShare.SetInfo
'error: ' + @ERROR + ' ' + @SERROR

Top
#154481 - 2006-01-03 06:36 AM Re: Error handling in ADSI
20thCenturyBoy Offline
Lurker

Registered: 2005-12-04
Posts: 4
Thanks, I thought the @ERROR macro was just for Kix-specific errors, not COM errors. Guess I was wrong!
Top
#154482 - 2006-01-03 03:05 PM Re: Error handling in ADSI
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
No need to break assume into 3 parts...
There is a UDF to translate COM error numbers.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#154483 - 2006-01-03 04:23 PM Re: Error handling in ADSI
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Plus - some of those COM error messages can be really long-winded, and Kixtart will wrap the text around so that you can't read'em. Use ...

$=SetOption("WrapAtEol","On")

... at the top of your script to see the full text.

Top
Page 1 of 1 1


Moderator:  Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 1198 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.053 seconds in which 0.026 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org