Page 1 of 2 12>
Topic Options
#33299 - 2002-11-22 10:32 PM Script not running....
Nick O'Connor Offline
Fresh Scripter

Registered: 2002-11-22
Posts: 12
So I got the environment variable part figured out.

If I run the script (which is launched via batch file) directly by mapping to the netlogon share, it works great.

If I just log the user in and expect it to run, I get an error from kixstart32.exe that it cannot find the script.

This is a 95 machine.

I have tried the script with both file extensions. (*.scr, and *.kix)

The login batch file:
login.bat

@ECHO OFF
Z:\KIX32.EXE envar.scr
(This is where I get the error)
net use h: /delete
net use h: "\\server\%username%$"
EXIT

envar.scr

? "Creating local user environment....."
SHELL "winset.exe USERNAME=@USERID"
Call envarmacro.bat
EXIT

envarmacro.bat

SHELL "winset.exe USERNAME=@USERID"
EXIT

Top
#33300 - 2002-11-22 10:38 PM Re: Script not running....
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
try simply changing this line:
Z:\KIX32.EXE envar.scr

to:
Z:\KIX32.EXE z:\envar.scr
_________________________
!

download KiXnet

Top
#33301 - 2002-11-22 10:40 PM Re: Script not running....
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
I have no clue what you're referring to. However, your scripts are messed up. The envarmacro.bat file contains KiXtart code?

Please state the purpose of your scripts, the KiXtart version running, OS suported and any other information.

You should also read ABC's of KiXtart board etiquette and message to new forum users and Kixtart Starter's Guide before your next post.

[ 22. November 2002, 22:42: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
#33302 - 2002-11-22 10:44 PM Re: Script not running....
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
jens, see how the macro is loaded.
by calling in from kix, so there is nothing wrong in that.
just the name is misleading.
_________________________
!

download KiXnet

Top
#33303 - 2002-11-22 10:51 PM Re: Script not running....
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Yeah, I guess, my mind is no longer capable of decyphering this mangled setup. Pretty much every line of code is totally opposite of what I would use and even hardcoding the Z: drive scares me.
I'd use
code:
use h: /delete /persistent
use h: '\\server\'+@USERID+'$$'

in the KiXtart script. But, hey, everybody is free to code as they like.
_________________________
There are two types of vessels, submarines and targets.

Top
#33304 - 2002-11-22 10:53 PM Re: Script not running....
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
hardcoding the z in win9x is better than using %0
as in nt it's better to use just exe name than %0
_________________________
!

download KiXnet

Top
#33305 - 2002-11-22 10:53 PM Re: Script not running....
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Well yeah... USE vs NET USE... if doing it in KiX. The guy does it in BAT however.

[ 22. November 2002, 22:54: Message edited by: LLigetfa ]
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#33306 - 2002-11-22 10:55 PM Re: Script not running....
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
it's netlogon bat...
for kix, there is no need to reference either as we have our macros.
_________________________
!

download KiXnet

Top
#33307 - 2002-11-25 03:18 PM Re: Script not running....
Nick O'Connor Offline
Fresh Scripter

Registered: 2002-11-22
Posts: 12
First off...

I am trying to set the environment variable for %username$ so that I can use that variable to map user home directories on Win9x.

I am using the latest version of Kix.

So if I understand correctly you are suggesting that I do that mapping in the actual Kix script?

Would that mean I would not need the third file at all then? I would prefer to run it all in one file if at all possible. The suggestion provided by Lonkero above, worked in that it ran and set the variable, but still did not map the drive.

I think this is because the script had not exited by the time the variable was set.

[ 25. November 2002, 15:24: Message edited by: Nick O'Connor ]

Top
#33308 - 2002-11-25 03:25 PM Re: Script not running....
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Map the all drives inside your KiXtart script. No need to set environment variables.

code:
If @Homeshr<>""
Dim $x
$x=Substr($Homeshr,3,len($Homeshr)-2)
$Hserver=Substr($x,1,instr($x,"\")-1)
$UserShare=Substr($x,instr($x,"\")+1,len($x)-instr($x,"\"))
Endif
If $HomeDrive<>"" and $Hserver<>"" and $UserShare<>""
MapDrive($HomeDrive, $Hserver, $UserShare)
else
Writelog("Home drive is either not defined or improperly defined for this user: Drive='" +
$HomeDrive + "', Server='" + $Hserver + "', Share='" + $UserShare + "'")
endif


Function MapDrive($Drive, $Server, $Share)
Dim $Drive, $Server, $Share
Color c+/n
If $Drive<>"" and $Server<>"" and $Share<>""
$LogText="Connecting $Drive to \\$Server\$Share"
? $LogText
USE $Drive /Delete /Persistent
USE $Drive "\\$Server\$Share"
If @error=0
color g+/n
$x=" - Success"
"$x"
Else
color r+/n
$x=" - Failed: Error @error"
"$x"
$ErrorState=1
Endif
WriteLog ($LogText + $x)
Color w+/n
Else
WriteLog ("Function 'MapDrive' called with invalid parameters: '$Drive', '$Server', '$Share'")
Endif
Endfunction

_________________________
Home page: http://www.kixhelp.com/hb/

Top
#33309 - 2002-11-25 03:35 PM Re: Script not running....
Nick O'Connor Offline
Fresh Scripter

Registered: 2002-11-22
Posts: 12
Apparently I am a moron, because that script makes zero sense to me.

I would assume you would call it from a login.bat file. Other than that, you totally lost me.

The method I have almost works, but not quite. Once the script stops running, I can map using the variable. But it will not map until the script ends.

I would love to try this one you provided, but not sure how to set it up.

Nor do I see how it helps me when the name of the share is \\server\username$

[ 25. November 2002, 15:54: Message edited by: Nick O'Connor ]

Top
#33310 - 2002-11-25 03:58 PM Re: Script not running....
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
If you properly define the home share in the account properties as "\\server\account$", then the code I provided will look it up and parse the server and share from the string.

You then simply pass the values to the MapDrive function to map the drive.

Let me know if this makes more sense.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#33311 - 2002-11-25 04:16 PM Re: Script not running....
Nick O'Connor Offline
Fresh Scripter

Registered: 2002-11-22
Posts: 12
Actually what works the best, and the simplest is what sealeapord suggested.

So the layout now is sipmly

login.bat

@ECHO OFF
Z:\KIX32.EXE Z:\userhome.kix
net use s: /delete
net use p: /delete
net use s: "\\server\share"
net use p: "\\server\share2"
EXIT

userhome.kix

? "Creating local user environment....."
SHELL "winset.exe USERNAME=@USERID"
use h: /delete /persistent
use h: '\\server\'+@USERID+'$$'
EXIT

Now comes the fun part. I have it working for that one department. Now I need to (Based on Group membership) alter the P and S drive mappings specified in the Login.bat file.

For example If you in HR, you need
\\server\share1 and \\server\share2

If your in Finance you need
\\server\share3 and \\server\share4

[ 25. November 2002, 16:18: Message edited by: Nick O'Connor ]

Top
#33312 - 2002-11-25 04:20 PM Re: Script not running....
Jack Lothian Offline
MM club member
*****

Registered: 1999-10-22
Posts: 1169
Loc: Ottawa,Ontario, Canada
Howard has taken things up a notch. He is using a User Defined Function(UDF) called MapDrive to do the mapping plus he is assuming the user share is defined in the user manager.

If you don't have the user share defined in the user manager you can still use the UDF but you must directly define the 3 variables $HomeDrive, $Hserver, $UserShare in your kix script then call MapDrive.

PS: With jens suggestion, I don't think you need the Winset. Also, don't share the group files in the logon.bat file, instead do it in the kix script since it has superior functions for detecting group membership. I strongly recommend you do a quick read of the kixtart manual. A quick scan of of 10 or 15 minutes will be very helpful.

[ 25. November 2002, 16:26: Message edited by: Jack Lothian ]
_________________________
Jack

Top
#33313 - 2002-11-25 04:25 PM Re: Script not running....
Nick O'Connor Offline
Fresh Scripter

Registered: 2002-11-22
Posts: 12
I appreciate howards, but would like to keep it simple. At least I can decipher what is running now.

I just need to find a good IF MEMBER type function to add in there.

Top
#33314 - 2002-11-25 04:30 PM Re: Script not running....
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Check the manual for InGroup().
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#33315 - 2002-11-25 04:41 PM Re: Script not running....
Darren_W Offline
Hey THIS is FUN
*****

Registered: 2001-10-10
Posts: 208
Loc: Bristol, England
Hi,

A typical example:

code:
  
If InGroup("Finance")

;map drives etc etc...

endif

Darren
_________________________
I want to share something with you - the three sentences that will get you through life.
Number 1, 'cover for me.'
Number 2, 'oh, good idea, boss.'
Number 3, 'it was like that when I got here'.

Top
#33316 - 2002-11-25 04:54 PM Re: Script not running....
Nick O'Connor Offline
Fresh Scripter

Registered: 2002-11-22
Posts: 12
Got it, thanks

Can you just list them? Like.....

? "Creating local user environment....."
SHELL "winset.exe USERNAME=@USERID"
use h: /delete /persistent
use h: '\\mercy-file\'+@USERID+'$$'
IF INGROUP("Groupname") USE P: '\\server\'share'
USE S: '\\server\'share2'
Endif
EXIT

Top
#33317 - 2002-11-25 04:59 PM Re: Script not running....
Darren_W Offline
Hey THIS is FUN
*****

Registered: 2001-10-10
Posts: 208
Loc: Bristol, England
Hi,

Almost got it.

code:
 


SHELL "winset.exe USERNAME=@USERID" ;Don't think you need this?
use h: /delete /persistent
use h: '\\mercy-file\'+@USERID+'$$'

IF INGROUP("Groupname")
USE P: '\\server\'share'
USE S: '\\server\'share2'
Endif

EXIT

Darren
_________________________
I want to share something with you - the three sentences that will get you through life.
Number 1, 'cover for me.'
Number 2, 'oh, good idea, boss.'
Number 3, 'it was like that when I got here'.

Top
#33318 - 2002-11-25 05:05 PM Re: Script not running....
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
A couple of points. There is a possibility that the drive may already exist and persistent so it is considered best practise to delete it first.

Stuff between IF and ENDIF should be indented for readability.

EXIT should have a parameter so should be:

Exit 0

or
Exit 1
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
Page 1 of 2 12>


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

Who's Online
1 registered (Allen) and 675 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.168 seconds in which 0.112 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