rawsonm
(Fresh Scripter)
2007-10-18 05:29 PM
script runs, but use command gives error

Hello

I have a script at work that I am using on my church 2003 Advance server. Everything seems to work, but the ingroup or use command gives an error and the script fails.

These are xp workstations that are members of the domain and I am logged into the PC into the domain using an admin level user account. The kix files are in the netlogon area, and I have added the kix32.exe to the users profile setting on the AD users and computers setting for the users account.

From what I understand there is nothing to put on the XP pc and that I only need to dump the script and the kix files onto the netlogon folder.

What did I miss? I am running the most recent version of of the kix program from the web site.

thanks
mark


NTDOCAdministrator
(KiX Master)
2007-10-18 07:21 PM
Re: script runs, but use command gives error

What version of KiX and what error?

The only file needed is either KIX32.EXE or WKIX32.EXE for NT/2000/XP/2003/Vista


noobness
(Fresh Scripter)
2007-10-18 07:34 PM
Re: script runs, but use command gives error

Need to have the kix exe files plus the kix script in the sysvol (netlogon) and create a batch file that calls 'kix32.exe script.kix'. the batch file would be under the user account logon script in active directory. Pretty sure this is all in the manual.

JD


Glenn BarnasAdministrator
(KiX Supporter)
2007-10-18 07:39 PM
Re: script runs, but use command gives error

Batch file is not necessary.

If your script name is anything other than "kixtart.kix", you need to define both the Kix32.exe and the script name in your user's Logon Script profile setting. ie: kix32.exe logon.kix

I use this to great advantage - my profile contains "kix32.exe kixtart_test.kix", while everyone else's profile simply contains "kix32.exe". When I make changes to the login script, it is pushed out as "kixtart_test.kix", and it only works for me. When it passes testing, I copy it to "kixtart.kix" and everyone gets the new version.

Glenn


rawsonm
(Fresh Scripter)
2007-10-19 05:58 PM
Re: script runs, but use command gives error

Hello

I am using the kix 2010 4.53.

On the server netlogon, I have the files, the scipt. For the users profile in AD, I have kix32.exe for the profile.

It does run, but when it gets to the ingroup, or use command for mappings, it stops with some error that I can not see on the screen.

How do I create a log of what is going on?

This is the same script that I have at work and it works fine. the shares are setup, and I can get to them outside of the script. It just seems like the script/process/xp does not know what the use command is.

Where is the use command kept? Is that part of the kix program?

thanks
mark


Witto
(MM club member)
2007-10-19 07:02 PM
Re: script runs, but use command gives error

Maybe put something in your script like:
 Code:
Sleep 10 ;script waits for 10 seconds
Get $RC ;script waits for input of one char and puts it in variable $RC
It maybe gives you time to read the message.

Maybe you can post your code?


Gargoyle
(MM club member)
2007-10-19 08:27 PM
Re: script runs, but use command gives error

And yes USE is a built in command of KiX

Glenn BarnasAdministrator
(KiX Supporter)
2007-10-19 08:55 PM
Re: script runs, but use command gives error

After each command in question, add:
LMsg('ID', @ERROR, @SERROR)

"ID" should be something that describes the point in your script, like "Line 97".

Then add the LMsg() UDF to your script:
 Code:
Function LMsg($ID, $Err, $SErr)

  Dim $_

  $_ = RedirectOutput('C:\LoginErr.txt')
  'Error ' $Err ' occured at ' $ID ?
  '  ' $SErr ? ?
  $_ = RedirectOutput('')
  Exit $Err  ; exit with same error so @ERROR is not modified by this func
EndFunction


Run your code, then examine C:\LoginErr.log to see what happened. If the log is empty, the cause is bad coding - Kix is throwing an error that is terminating the script at the point of error. You could add a RedirectOutput to the beginning of the script, so all output, including Kix fatal errors, will be in the log. Also, you can try Kix 4.6, which will write fatal errors to the application event log.

Glenn





Richard H.Administrator
(KiX Supporter)
2007-10-23 01:24 PM
Re: script runs, but use command gives error

Have you tried opening a DOS prompt and running the script manually? If the script is abending then you will see the error(s).

If the script runs OK then the error is probably related to the way that you are calling the script.

If your script does not contain sensitive information then post it here for review - sometimes it just needs another set of eyes to look at the problem.


Arend_
(MM club member)
2007-10-23 01:38 PM
Re: script runs, but use command gives error

Is it just me who finds this part interesting "church 2003 Advance server"

- A Church having a server.
- 2003 Advanced Server ? Either 2003 Standard/Web/Enterprise/Datacenter or 2000 Advanced server.
- Church 2003 Advanced Server isn't any OS I've ever heard of, then again I'm not much into religion anyway ;\)


Glenn BarnasAdministrator
(KiX Supporter)
2007-10-23 01:41 PM
Re: script runs, but use command gives error

Richard!!

DOS prompt? You of all people should know that the last DOS prompt went extinct with the death of WinTyrantSoreUs-Doze98! \:o Even though the species attempted to survive the new millenium, the offspring was weak and did not survive.

Other than that, I'd do pretty much the same thing, except I'd use the COMMAND prompt. ;\)

Glenn


NTDOCAdministrator
(KiX Master)
2007-10-23 11:11 PM
Re: script runs, but use command gives error

Well it's not a COMMAND "promp" either it's a "command interpreter" that has an underlying PIF entry that defaults to "Command Prompt" but could be named anything. ;\)

Glenn BarnasAdministrator
(KiX Supporter)
2007-10-24 04:22 AM
Re: script runs, but use command gives error

Yeah, yeah, whatever, just don't call it "DOS"! ;\)

NTDOCAdministrator
(KiX Master)
2007-10-24 09:21 AM
Re: script runs, but use command gives error

LOL - Okay boss, I hear ya - but to be honest most people understand or know what you mean even if they're on Linux when you call it a DOS Prompt.

Arend_
(MM club member)
2007-10-24 09:50 AM
Re: script runs, but use command gives error

Or just command.com ;\)
Then again there is DosBox.exe that emulates true dos... \:\)


Gargoyle
(MM club member)
2007-10-24 03:21 PM
Re: script runs, but use command gives error

 Code:
Open 8,1 "testfile"


rawsonm
(Fresh Scripter)
2007-10-26 03:32 PM
Re: script runs, but use command gives error

Hello Glenn

thanks for the great code, I will test this weekend. For people that were asking, no there is not a church version of the OS, I am working on this issue at my church. The software is Windows 2003 advanced server.

For anyone that wanted to see the code, here it is. As stated before, I am using the exact same code at work with no problems.

As stated before, I am calling with with a kix32.exe in the users AD profile for login script.

thanks for all the great comments and help.

mark


NTDOCAdministrator
(KiX Master)
2007-10-26 07:16 PM
Re: script runs, but use command gives error

Think the guys were joking with you a bit. There is no "Windows 2003 advanced server"

The basic versions of Server 2003 are:
  • Standard Edition
  • Enterprise Edition
  • Datacenter Edition
  • Web Edition


Now they're doing R2 versions and Server 2008 is just around the corner.

Will take a look at your code and see if I see anything obvious. I see 3 others have downloaded it as well.


NTDOCAdministrator
(KiX Master)
2007-10-26 07:36 PM
Re: script runs, but use command gives error

Okay, here is your script and my comments. Though no issues for why it would not run (might not be the best but should still run)

Does the console come up and in a Maximum state for the user when they logon or nothing happens?

 Code:
If Not @LogonMode
  Break On
Else
  Break Off
EndIf
CLS
Dim $SO
$SO=SetOption('Explicit','On')
$SO=SetOption('NoVarsInStrings','On')
$SO=SetOption('NoMacrosInStrings','On')
$SO=SetOption('WrapAtEOL','On')
$SO=SetTitle('Church Login Script')
$SO=SetConsole('maximize')
Dim $x

;Should add either the name of the Domain or the macro for current Domain
If InGroup(@Domain+'\church_admin')
    use L: /delete /persistent
    use M: /delete /persistent

	;Really don't see the need for setting it persistent if you're 
    ;going to map it every logon and delete it every logon
    ;(yes parameter not needed)
    use L: \\bcbkup01\avfoldera /persistent
    use M: \\bcbkup01\avfolderb /persistent
EndIf

If InGroup(@Domain+\'churchusers')
    use J: /delete
    use J: "\\bcbkup01\images" /persistent
EndIf
;No need to clear screen again as you have not shown anything yet
cls

Color r+/n

small
Color R+/n
BOX (0,0,24,79,GRID)            ; 'background grid'
Color b/n
BOX (8,21,18,61,Å)              ; 'shadow' of the box
Color g+/n
BOX (7,20,17,60,FULL)

Color w+/n
AT ( 9,25) "Userid       : "    ; display some text strings
AT (10,25) "Full name    : "
AT (11,25) "Privilege    : "
AT (12,25) "Workstation  : "
AT (13,25) "Domain       : "
AT (14,25) "Logon Server : "

Color y+/n
AT ( 9,40) @userid              ; ...and some macro's
AT (10,40) @fullname
AT (11,40) @priv
AT (12,40) @wksta
AT (13,40) @domain
AT (14,40) @lserver

Color w/n
sleep 2

cls
;Should be in quotes and should be in the NETLOGON share
Display 'message.txt'

sleep 2

cls

;Do not see why this is here, you do not seem to use it for anything
$x = SubStr(@ipaddress0,7,1)

If Open(3 ,'\\bcbkup01\log\log.txt' ,5) = 0
	$x = WriteLine(3,"User:  " + @fullname + "  " + @userid + "  " + @wksta  +"  Logged on  " + @date + "   " + @time + "   " + @ipaddress0  +@CRLF)
Else
	? "Failed to open file, error code : [" + @error + "]"
EndIf

;Need to sleep or something otherwise if you want to show this error 
;otherwise the user will not have time to see it
Sleep 3
cls
;What is in this timeset.cmd file?  On an Active Directory you should
;not be setting the time as it is automated now days
;Regardless you should also run it with comspec
; Shell '%comspec% /c \\churchdomain\netlogon\timeset.cmd '
shell "\\churchdomain\netlogon\timeset.cmd"

;You should either provide an @ERROR exit or a given exit code 
exit



Witto
(MM club member)
2007-10-26 07:45 PM
Re: script runs, but use command gives error

I would wrap strings in quotes like documented in kix2010.doc
 Code:
use "L:" "\\bcbkup01\avfoldera" /persistent


NTDOCAdministrator
(KiX Master)
2007-10-26 07:48 PM
Re: script runs, but use command gives error

Actually that is old documentation and not using quotes on the driver letter works perfectly fine.

Regardless that would NOT prevent the script from running.


Glenn BarnasAdministrator
(KiX Supporter)
2007-10-26 08:15 PM
Re: script runs, but use command gives error

 Originally Posted By: NTDOC
Think the guys were joking with you a bit. There is no "Windows 2003 advanced server"


You didn't think the advice here was "free", did ya? ;\)
Certainly not free of teasing, joking, and general good-natured (mostly) ribbing.

Glenn


rawsonm
(Fresh Scripter)
2007-11-01 07:57 PM
Re: script runs, but use command gives error

Hello Glenn,

I ran your trouble shooting script and found that it has problems only with the use command. Everything else in the scipt runs ok. The use command exits with a 0 code and says that is completed ok, but there is no mapping.

I think that I might have found the problem. Most shares that I map with the login script are regular shares, not $ hidden ones. Is there anything special I need to do since the shares that I am mapping are hidden NT/2000 shares? I have never tried to use Kix to map a hidden share before.

Side question, when do you use wkix32?

thanks
mark


rawsonm
(Fresh Scripter)
2007-11-01 08:00 PM
Re: script runs, but use command gives error

Hello

I think I found the problem. This is the first time that I have tried to map to a hidden share $ with the kix script. In the past, all shares have been regular ones. What do I need to know about using the Kix use command with hidden network shares?

mark


Glenn BarnasAdministrator
(KiX Supporter)
2007-11-01 08:31 PM
Re: script runs, but use command gives error

Regarding the share mapping, it might be good for you to start with a clean slate - removing existing shares and disabling share persistence.

As for WKix/Kix - on my systems, I associate .KIX with Kix32 and .KXW with WKix32. This is done only on servers and admin workstations - not universally. If I'm running a .KIX script, it's always at the command line (I will never launch a script of any kind via double-clicks in explorer!), so Kix32 is appropriate. If my script is a system service, or uses Kixforms GUI, it has a .KXW extension. These usually have desktop or start-menu icons, since the interface is graphical.


Glenn


rawsonm
(Fresh Scripter)
2007-11-02 01:32 AM
Re: script runs, but use command gives error

Hello

I tested tonight and have confirmed the issue. Kix does not like to use the use command to map hidden shares. I removed the $ from all my shares and made them regular shares and the script ran fine and the mappings are there.

Thanks for all your help everyone.
mark


Les
(KiX Master)
2007-11-02 02:17 AM
Re: script runs, but use command gives error

What version of KiX?
Do you use any zero-length var names?
i.e.
$ = function()


NTDOCAdministrator
(KiX Master)
2007-11-02 02:55 AM
Re: script runs, but use command gives error

Something in how you're coding as KiX has no problem mapping a hidden share. I use it here just fine.

Try adding this at the top of your script

If Not @LogonMode
Break On
EndIf
Dim $SO
$SO=SetOption('Explicit','On')
$SO=SetOption('NoVarsInStrings','On')
$SO=SetOption('NoMacrosInStrings','On')
$SO=SetOption('WrapAtEOL','On')


Richard H.Administrator
(KiX Supporter)
2007-11-02 09:32 AM
Re: script runs, but use command gives error

 Originally Posted By: rawsonm
I tested tonight and have confirmed the issue. Kix does not like to use the use command to map hidden shares.


This is not correct.

KiXtart has no problem mapping "hidden" shares where the share name is suffixed with a "$".

If you are having problems then it is something peculiar to your environment.

The only special handling that you need for hidden shared is that the trailing "$" may be considered to be a variable embedded in the string, in which case you need to ensure that it is protected.

However "hidden" shares are not any sort of security and only really useful for reducing clutter when browsing, so if you are happy with the solution of not using them then stick with that.

If you *do* need to map hidden shares with KiXtart then post again and we'll assist you in finding out why it's not working for you.


Glenn BarnasAdministrator
(KiX Supporter)
2007-11-02 12:28 PM
Re: script runs, but use command gives error

I think Doc's got this nailed...

USE D: "\\server\hidden$"
will not work unless NoVarsInStrings is declared. However -
USE D: "\\server\hidden" + Chr(36)
will always work.

Without either of these minor modifications, Kix is treating the "$" at the end of the share name as a variable, and since the var "$" is likely empty, nothing (or something invalid) appears after the text part of the share name. This prevents it from mapping.

If you follow ALL of Doc's advice, however, be prepared for lots of other things failing. You said you got this script from work, and someone else wrote it?? If it wasn't written to the standards needed for all the SetOption values that Doc referenced, especially Explicit, more things will fail than will be fixed. Your code must be written to permit those settings (which are, in turn, designed to force good coding habits).

I'd suggest that you first map your hidden shares using the form
USE D: "\\server\hidden" + Chr(36)

Confirm that it works. Then, make a copy of the login script (kixtart2.kix) and add the SetOption statements Doc suggested. Run the script - when it fails due to an "Undefined Variable: xxx", you can add a statement to your code to declare it. You can simply DIM them all on one or two lines, but I now prefer one DIM per variable (or var group) with a comment that reminds me what they are for. For example:
 Code:
Dim $x,$y            ; Index pointers
Dim $aHosts, $Host   ; Array of host names, For/Each enumerator
Dim $Share           ; name of share to be mapped

You will also need to scan the code and change statements like this:
"You logged in at @TIME on @DATE" ?
to this:
"You logged in at " @TIME " on " @DATE ?
since macros will not be processed inside strings if you declare NoMacrosInStrings as he suggested.

Keep in mind that you SHOULD follow Doc's suggestions - they assure good coding practices and eliminate many problems such as you are encountering. The caveat is that they ENFORCE good practices - if your code isn't written that way, it won't help. It's not a magic bullet or anything..

Glenn


Benny69
(MM club member)
2007-11-02 12:58 PM
Re: script runs, but use command gives error

I am sure Glen just had a typo, but:
this:
"You logged in at @TIME on @DATE" ?
should be:
"You logged in at " + @TIME + " on " + @DATE ?


Glenn BarnasAdministrator
(KiX Supporter)
2007-11-02 02:20 PM
Re: script runs, but use command gives error

No, it shouldn't. The "+" is required only if you are building a string for assignment, not if you are simply printing. It's allowed to use concatenation in output, but it's definitely not required. If you think about the manual reference, any string or variable not part of an "assignment" is simply output. So - my presentation is simply the output of a series of fixed strings and variables.

Besides, Dale, if anyone had a typo, it's you! I have TWO "n"'s in my name!! \:D (and while you prolly wouldn't want me to call you "Dal", "Ale" might be interesting for a bit.. ;\) )

Glenn

PS - I'm not sensitive about the spelling, but enjoy every opportunity to tease!


AllenAdministrator
(KiX Supporter)
2007-11-02 02:39 PM
Re: script runs, but use command gives error

Glenn of all people, has no business telling people how to spell names (sheesh!)

Benny69
(MM club member)
2007-11-02 02:46 PM
Re: script runs, but use command gives error

you guys are tooo funny ;\)

Glenn BarnasAdministrator
(KiX Supporter)
2007-11-02 02:55 PM
Re: script runs, but use command gives error

Wassup with you, Alan? er.. Allen! \:D

Richard H.Administrator
(KiX Supporter)
2007-11-02 06:30 PM
Re: script runs, but use command gives error

I feel your pain, I spend so much time being Howard I'm officially liable for double taxation!

NTDOCAdministrator
(KiX Master)
2007-11-03 05:38 AM
Re: script runs, but use command gives error

What did you say Howard, you're feeling pain? Take two aspirin and call me in the morning. ;\)

Glenn BarnasAdministrator
(KiX Supporter)
2007-11-03 01:43 PM
Re: script runs, but use command gives error

Hmm..

I thought it would have been "perform two netstats and ping me in the morning".

G-


Mart
(KiX Supporter)
2007-11-03 04:33 PM
Re: script runs, but use command gives error

LOL

Howard Bullock
(KiX Supporter)
2007-11-04 01:39 PM
Re: script runs, but use command gives error

Richard, It ia good the you represent me on the board during the time when my visits are not so frequent.