Page 1 of 1 1
Topic Options
#209556 - 2014-10-21 05:38 PM Launch main script manually but secondary script not executed
yellowdog Offline
Starting to like KiXtart

Registered: 2005-06-14
Posts: 102
Hello,

I have a main script that is calling others script based on the @primarygroup.
All my scripts are located in the \\DomainServer\Netlogon share, and work fine at logon.

But I'd like to run manually the same script. When I run the main script manually the call to others script does not work.

What's the solution to my problem ?

Thanks.

Top
#209557 - 2014-10-21 05:44 PM Re: Launch main script manually but secondary script not executed [Re: yellowdog]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
Not sure why you are having trouble, but try replacing @primarygroup with the following UDF, and see if it helps.

GetPrimaryGroup() -
http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=204238#Post204238

How to use UDFs -
http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=81943#Post81943

The rest of the UDFs are here -
http://www.kixtart.org/forums/ubbthreads.php?ubb=postlist&Board=7&page=1

Top
#209558 - 2014-10-21 06:02 PM Re: Launch main script manually but secondary script not executed [Re: Allen]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
Also, by "works fine during logon", if you are running the script as GPO Startup Script, it will run in a different context than if you run it manually by the user. GPO scripts run with permissions as System, where as when you run the script manually it runs with the permissions of the user.
Top
#209559 - 2014-10-21 07:19 PM Re: Launch main script manually but secondary script not executed [Re: yellowdog]
ChristopheM Offline
Hey THIS is FUN
*****

Registered: 2002-05-13
Posts: 311
Loc: STRASBOURG, France
why call to others scripts does not work ?
is it test for member ship that fails or is it access to script ?

usually, i use "call @scriptdir+"\my second script.kix"

could you post an example of mis-functionning code ?

Christophe
_________________________
Christophe

Top
#209560 - 2014-10-22 02:09 AM Re: Launch main script manually but secondary script not executed [Re: ChristopheM]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
Yea... Path is my quess as well.
_________________________
!

download KiXnet

Top
#209564 - 2014-10-22 10:24 AM Re: Launch main script manually but secondary script not executed [Re: ChristopheM]
yellowdog Offline
Starting to like KiXtart

Registered: 2005-06-14
Posts: 102
I think that the problem I encounter is related to the Scriptdir macro.

In fact I try to execute my main script that is located on the \\DomainDC\netlogon from aworkstation where the logon process is already performed.

I created a little script invoking the main script on NETLOGON share, and when I display the @scriptdir from this script, it display the local directory from the workstation C:\TEMP instead of \\DomainDC\netlogon.
That's why it cannot chain the others scripts located on NETLOGON.

Is there a way to initialize the @scriptdir macro to a certain value ?

Top
#209565 - 2014-10-22 10:35 AM Re: Launch main script manually but secondary script not executed [Re: yellowdog]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Did you package the script into an executable? They are unpacked in the temp folder and then executed.

What if you change it to @LDRIVE?
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#209566 - 2014-10-22 10:51 AM Re: Launch main script manually but secondary script not executed [Re: Mart]
yellowdog Offline
Starting to like KiXtart

Registered: 2005-06-14
Posts: 102
I changed all my call from my main script to: CALL @LDRIVE\2nd_script.kix
CALL @LDRIVE\3rd_script.kix
.......
But it doesn't change, now the problem is linked with the @primarygroup which is blanked.

I inserted the UDF in the main script and the UDF returns: "defaultNamingContext1"

What do you suggest me to do.


Edited by yellowdog (2014-10-22 11:45 AM)

Top
#209567 - 2014-10-22 01:06 PM Re: Launch main script manually but secondary script not executed [Re: yellowdog]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
During the logon process, the NetLogon folder is in the System PATH, thus, Kix scripts run without issue. After logon, this folder is not in the path.

There's no issue with @SCRIPTDIR if you're calling Kix locally but specifying the path to the scripts.. It's the directory where you called kix from, not where Kix or scripts are. For that, you need @STARTDIR.

Try running from the netlogon share directly:
\\DOMAIN\NetLogon\Kix32 \\DOMAIN\NetLogon\MainKixScript.kix
where "DOMAIN" is your local AD domain name.

My login script dumps info when debug mode is active, and you can see the results of these macros:
During logon:
 Code:
       Logon Mode: 1
           Laptop: 0
     Detected O/S: Windows 8 Professional Edition / Version 6.2
        Privelege: USER
  Local Privelege: User
        ScriptDir: C:\Windows\system32 / C:\Windows\system32
         StartDir: \\Ihwiadcp01\netlogon
CMD Prompt after logon:
 Code:
       Logon Mode: 0
           Laptop: 0
     Detected O/S: Windows 8 Professional Edition / Version 6.2
        Privelege: USER
  Local Privelege: User
        ScriptDir: \\itcg\netlogon / \\itcg\netlogon
         StartDir: \\itcg\netlogon
This should properly set the @STAPTDIR macro because you're calling kix32 from the same place as your scripts. The @SCRIPTDIR isn't even relevant during logon! Note that @SCRIPTDIR is effectively the same - when logging in, it's the specific DC that processed the logon, while run later, it's the DOMAIN path (Any DC).

Thus - STARTDIR is what you should use to call your scripts from the NetLogon folder. \:\)

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#209568 - 2014-10-22 01:39 PM Re: Launch main script manually but secondary script not executed [Re: Glenn Barnas]
ChristopheM Offline
Hey THIS is FUN
*****

Registered: 2002-05-13
Posts: 311
Loc: STRASBOURG, France
if you have problem with the macro @scriptdir, you can try the following piece of code
 Code:
if @LogonMode
	$scriptdir = %LOGONSERVER%+"\Netlogon"
else
	$scriptdir = @Scriptdir
endif

"scriptdir : " $scriptdir ?

During login script, the script already loads sub-script from netlogon.
If launched interactively, it loads sub-script from the directory of the script itself.


Edited by ChristopheM (2014-10-22 01:41 PM)
_________________________
Christophe

Top
#209576 - 2014-10-23 10:25 AM Re: Launch main script manually but secondary script not executed [Re: ChristopheM]
yellowdog Offline
Starting to like KiXtart

Registered: 2005-06-14
Posts: 102
Maybe I forgot to tell you that I launch manually the script after having initiated a VPN connection from a laptop to the domain.

Thanks for all of you guys to help me solve that problem. I changed in my main script the call to others script using the @startdir macro, but still does not work.

I have access to the \\Domain\netlogon share, but my main script is linked with the user's primarygroup, then according to the primarygroup tested it calls an other script.

Then my major problem is to detect that primarygroup that remains blank when I launch the script manually.
I tested also the UDF script but the result is the same.

An LDAP request would not be the solution instead of a WinNt ?

Is there a solution to my problem ?


Edited by yellowdog (2014-10-23 11:59 AM)

Top
#209577 - 2014-10-23 02:49 PM Re: Launch main script manually but secondary script not executed [Re: yellowdog]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
This all sounds like a DNS/Wins/Hosts file issue to me. The client probably can't find the Domain Controller, or some other server that your scripts are linked to. I have used the following trick to "fix" VPN issues before with some success:

 Quote:

Domain Browsing with LMHOSTS
Without WINS, you need special LMHOSTS entries that designate who all the
domain controllers are. This is done in the following convention:
199.199.199.1 ComputerName #PRE #DOM:DomainName

When a computer is booted, it reads these entries and store them permanently
in the NetBIOS name cache until the computer is powered down. (Because of
this, it is best that these entries are last in the LMHOSTS file, for
subsequent LMHOSTS parsing efficiency.) All computers in the domain needs
one of these entries for each domain controller (in the local domain), as
well as one for the PDC. Also note the exact order of #PRE #DOM, and that
they are capitalized. The other names are not case sensitive.


BTW, the GetPrimaryGroup() UDF is using ldap.

Top
#209579 - 2014-10-23 05:46 PM Re: Launch main script manually but secondary script not executed [Re: Allen]
yellowdog Offline
Starting to like KiXtart

Registered: 2005-06-14
Posts: 102
I configured the LMHOST file but nothing changed. Still having problems executing the NETLOGON script.

Attached is the script.

 Code:
 ;          *******************************************************
;          *                 SCRIPT PAR DEFAUT                   *
;          *******************************************************


SETCONSOLE(SHOW)

IF INGROUP("GRP_CPTR_GB") <> 0
   REDIRECTOUTPUT ("\\STSANSI1\Profils\@USERID\Script.log", 1)
ELSE
   REDIRECTOUTPUT ("%USERPROFILE%\Script.log", 1)
ENDIF


$D=@DOMAIN
$S=@LSERVER
$U=@USERID
$version=@DOS

$NbErreur = 0


;***************************************************************************************************************
; Suppression de la valeur CodeBaseSearchPath qui ouvre une connexion sur internet à l'ouverture du client NOTES
; et  Suppression de la case à cocher pour l'enregistrement du mot de passe à l'authentification du PROXY
;***************************************************************************************************************
IF $version = "5.0" or $version = "5.1" or $version = "6.1"
   DelValue("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Internet Settings","CodeBaseSearchPath")
   shell "cscript.exe \\G2K8ARB01\netlogon\DisablePasswordCache.VBS" 
ELSE
ENDIF

IF INGROUP("GRP_PROXY_NOSCRIPT") <> 0
   EXIT
ENDIF


   $CITRIX = @WKSTA
   IF $CITRIX="G2K3CIT1" OR $CITRIX="G2K3CIT2" OR $CITRIX="G2K3CIT3" OR $CITRIX="G2K3CIT4"
   ; 	ajout d'une variable d'environnement pour TERMINAL SERVEUR  
   ; 	nous déplacerons ensuite DANS LES GROUPES SI BESOIN 
   ;	"connaissance du nom de l'utilisateur par terminal serveur"
    	WriteValue("HKEY_CURRENT_USER\Environment", "TSNAME", "", "REG_SZ")
	WriteValue("HKEY_CURRENT_USER\Environment", "TSNAME", "$U", "REG_SZ")
	EXIT
   ELSE
   ENDIF

   $SRVNAME = @WKSTA 
   IF $SRVNAME="V2K3GOUV2" OR $SRVNAME="V2K3CITAPP01"  OR $SRVNAME="V2K3CITAPP02" OR $SRVNAME="V2K3CITDC" OR $SRVNAME="G2K8DL01"
   	EXIT
   ELSE
   ENDIF

;***********************************************************************
; Récupération de l'heure du domaine
;***********************************************************************

IF $SRVNAME="V2K3CITDK01" 
   	GOTO SKIPTIME
   ENDIF

SETTIME "$S"
IF @ERROR = 0
   "Récupération de l'heure sur le serveur"
ELSE
   "Heure domaine non récupérée : erreur " @ERROR
   $NbErreur = $NBErreur + 1
ENDIF


:SKIPTIME
? "Connexion au domaine $D le @MDAYNO/@MONTHNO/@YEAR à @TIME"
? "Serveur d'authentification : $S"
? "Groupe utilisateur : " @PRIMARYGROUP
? "Version de l'OS = "$version

;**********************************************************************
; Paramètres internationnaux
;**********************************************************************

$Row = ReadValue("HKEY_CURRENT_USER\Control Panel\International", "sDecimal")
IF @ERROR <> 0
   ? "sDecimal erreur : " @ERROR
   $NbErreur = $NBErreur + 1
ENDIF
IF $Row <> ","
   WriteValue("HKEY_CURRENT_USER\Control Panel\International", "sDecimal", ",", "REG_SZ")
   IF @ERROR = 0
	? " Nouvelle valeur sDecimal : ,"
   ELSE
	? "Erreur sur écriture clé sDecimal, erreur : " @ERROR
	$NbErreur = $NBErreur + 1
   ENDIF
ENDIF

$Row = ReadValue("HKEY_CURRENT_USER\Control Panel\International", "sThousand")
IF @ERROR <> 0
   ? "sThousand erreur : " @ERROR
   $NbErreur = $NBErreur + 1
ENDIF
IF $Row <> " "
   WriteValue("HKEY_CURRENT_USER\Control Panel\International", "sThousand", " ", "REG_SZ")
   IF @ERROR = 0
	? " Nouvelle valeur sThousand : "
   ELSE
	? "Erreur sur écriture clé sThousand, erreur : " @ERROR
	$NbErreur = $NBErreur + 1
   ENDIF
ENDIF

$Row = ReadValue("HKEY_CURRENT_USER\Control Panel\International", "sMonDecimalSep")
IF @ERROR <> 0
   ? "sMonDecimalSep erreur : " @ERROR
   $NbErreur = $NBErreur + 1
ENDIF
IF $Row <> ","
   WriteValue("HKEY_CURRENT_USER\Control Panel\International", "sMonDecimalSep", ",", "REG_SZ")
   IF @ERROR = 0
	? " Nouvelle valeur sMonDecimalSep : ,"
   ELSE
	? "Erreur sur écriture clé sMonDecimalSep, erreur : " @ERROR
	$NbErreur = $NBErreur + 1
   ENDIF
ENDIF

$Row = ReadValue("HKEY_CURRENT_USER\Control Panel\International", "sMonThousandSep")
IF @ERROR <> 0
   ? "sMonThousandSep erreur : " @ERROR
   $NbErreur = $NBErreur + 1
ENDIF
IF $Row <> " "
   WriteValue("HKEY_CURRENT_USER\Control Panel\International", "sMonThousandSep", " ", "REG_SZ")
   IF @ERROR = 0
	? " Nouvelle valeur sMonThousandSep : "
   ELSE
	? "Erreur sur écriture clé sMonThousandSep, erreur : " @ERROR
	$NbErreur = $NBErreur + 1
   ENDIF
ENDIF

$Row = ReadValue("HKEY_CURRENT_USER\Control Panel\International", "sList")
IF @ERROR <> 0
   ? "sList erreur : " @ERROR
   $NbErreur = $NBErreur + 1
ENDIF
IF $Row <> ";"
   WriteValue("HKEY_CURRENT_USER\Control Panel\International", "sList", ";", "REG_SZ")
   IF @ERROR = 0
	? " Nouvelle valeur sList : ;"
   ELSE
	? "Erreur sur écriture clé sList, erreur : " @ERROR
	$NbErreur = $NBErreur + 1
   ENDIF
ENDIF


;*********************************************************************
; Groupes 
;*********************************************************************
IF $U="pppp"
   CALL @SCRIPTDIR\GRPCATIA_PPPP.kix
   $Groupe = "OK"
ENDIF	

IF INGROUP("GRPNOBAT") <> 0
   CALL @SCRIPTDIR\GRPNOBAT.kix
   $Groupe = "OK"
ENDIF

IF INGROUP("GRPACHATS") <> 0
   CALL @SCRIPTDIR\GRPACHATS.kix
   $Groupe = "OK"
ENDIF

IF INGROUP("GRPCOMDPC") <> 0
   CALL @SCRIPTDIR\GRPCOMDPC.kix
   $Groupe = "OK"
ENDIF

IF INGROUP("GRPCOMMERCE") <> 0
   CALL @SCRIPTDIR\GRPCOMMERCE.kix
   $Groupe = "OK"
ENDIF

IF INGROUP("GRPCOMPTA") <> 0
   CALL @SCRIPTDIR\GRPCOMPTA.kix
   $Groupe = "OK"
ENDIF

IF INGROUP("GRPDG") <> 0
   CALL @SCRIPTDIR\GRPDG.kix
   $Groupe = "OK"
ENDIF

IF INGROUP("GRPDRH") <> 0
   CALL @SCRIPTDIR\GRPDRH.kix
   $Groupe = "OK"
ENDIF

IF INGROUP("GRPETUDES") <> 0
   CALL @SCRIPTDIR\GRPETUDES.kix
   $Groupe = "OK"
ENDIF

IF INGROUP("GRPFINANCE") <> 0
   CALL @SCRIPTDIR\GRPFINANCE.kix
   $Groupe = "OK"
ENDIF

IF INGROUP("GRPGESTION") <> 0
   CALL @SCRIPTDIR\GRPGESTION.kix
   $Groupe = "OK"
ENDIF

IF INGROUP("GRPINFO") <> 0
   CALL @SCRIPTDIR\GRPINFO.kix
   $Groupe = "OK"
ENDIF

IF INGROUP("GRPCATIA") <> 0
   CALL @SCRIPTDIR\GRPCATIA.kix
   $Groupe = "OK"
ENDIF


IF INGROUP("GRPSUPCHAIN") <> 0
   CALL @SCRIPTDIR\GRPSUPCHAIN.kix
   $Groupe = "OK"
ENDIF

IF INGROUP("GRP_BDR") <> 0
   CALL @SCRIPTDIR\GRP_BDR.kix
   $Groupe = "OK"
ENDIF

IF INGROUP("GRPCER") <> 0
   CALL @SCRIPTDIR\GRPCER.kix
   $Groupe = "OK"
ENDIF

IF INGROUP("GRPCH") <> 0
   CALL @SCRIPTDIR\GRPCH.kix
   $Groupe = "OK"
ENDIF

IF INGROUP("GRPDL") <> 0
   CALL @SCRIPTDIR\GRPDL.kix
   $Groupe = "OK"
ENDIF

IF INGROUP("GRPENTPL") <> 0
   CALL @SCRIPTDIR\GRPENTPL.kix
   $Groupe = "OK"
ENDIF

IF INGROUP("GRPES") <> 0
   CALL @SCRIPTDIR\GRPES.kix
   $Groupe = "OK"
ENDIF

IF INGROUP("GRPIT") <> 0
   CALL @SCRIPTDIR\GRPIT.kix
   $Groupe = "OK"
ENDIF

IF INGROUP("GRPNL") <> 0
   CALL @SCRIPTDIR\GRPNL.kix
   $Groupe = "OK"
ENDIF

IF INGROUP("GRPPARIS") <> 0
   CALL @SCRIPTDIR\GRPPARIS.kix
   $Groupe = "OK"
ENDIF

IF INGROUP("GRPREPRO") <> 0
   CALL @SCRIPTDIR\GRPREPRO.kix
   $Groupe = "OK"
ENDIF

IF INGROUP("GRPPRODDPC") <> 0
   CALL @SCRIPTDIR\GRPPRODDPC.kix
   $Groupe = "OK"
ENDIF

IF INGROUP("GRPPRODDPE") <> 0
   CALL @SCRIPTDIR\GRPPRODDPE.kix
   $Groupe = "OK"
ENDIF

IF INGROUP("GRPPRODDPI") <> 0
   CALL @SCRIPTDIR\GRPPRODDPI.kix
   $Groupe = "OK"
ENDIF

;*********************************************************************
; Message box
;*********************************************************************

IF $Groupe <> "OK"
   ? "Pas de fichier script pour le groupe"
   MESSAGEBOX("Aucun script n'est associé au groupe : @PRIMARYGROUP, 
   Contactez l'administrateur du réseau", "Script de lancement", 64)
ELSE
   If $NbErreur = 0
	MESSAGEBOX ("Bienvenue dans le domaine @DOMAIN, contrôleur local @LSERVER
                                          . . .
                                 Lancement OK",
	"Script de lancement", 64)
   ELSE
	MESSAGEBOX ("Bienvenue dans le domaine @DOMAIN, contrôleur local @LSERVER
                                         . . .
            $NbErreur anomalie(s) détectée(s) lors du lancement
                 Contactez l'administrateur du réseau
                                         . . .",
	"Script de lancement", 16)
   ENDIF
ENDIF
?
EXIT


Top
#209580 - 2014-10-23 09:03 PM Re: Launch main script manually but secondary script not executed [Re: yellowdog]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
Clearly your script still calls @scriptdir

On top of that, the string is not quoted.
_________________________
!

download KiXnet

Top
#209581 - 2014-10-23 10:29 PM Re: Launch main script manually but secondary script not executed [Re: Lonkero]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
You should determine if all the related groups are available via the VPN - often if you don't log into the network via the VPN, they won't be.

You can use the attached diag tool (tokenized with Kix 4.62 as it is part of our proprietary login script) or you can download our login script, create a LoginDebug.log file in your %USERPROFILE% folder and run the script. It will run in debug mode by default using the test config file, but it will dump several diagnostic settings, including the environment and the list of all groups you're a member of. The diag tool just dumps the group membership list.

This will at least prove if your code is failing because the group memberships can't be determined.

Glenn


Attachments
ListGroups.zip (821 downloads)
Description:


_________________________
Actually I am a Rocket Scientist! \:D

Top
#209586 - 2014-10-27 03:31 PM Re: Launch main script manually but secondary script not executed [Re: Glenn Barnas]
yellowdog Offline
Starting to like KiXtart

Registered: 2005-06-14
Posts: 102
Thanks Glenn for your help.

I ran your script, and the membership is OK for the user.
Then I modified the script with the recommendations of Lonkero, and now I'm facing a problem with the error 1265 when trying to mount the differents shares.

 Code:
 1265 ERROR_DOWNGRADE_DETECTED The system detected a possible attempt to compromise security. Please ensure that you can contact the server that authenticated you. 


I checked my Domain Controller Policy and verified that the following GPO is already set.

 Code:
1.Logon to a Windows Server 2008-based domain controller.
2.Click Start, Run, type gpmc.msc, and then click OK.
3.In the Group Policy Management console, expand Forest: DomainName, Controller, Domain Controllers, right-click Default Domain Controllers Policy, and then click Edit.
4.In the Group Policy Management Editor console, expand Computer Configuration, Policies, Administrative Templates, System, click Net Logon, and then double-click Allow cryptography algorithms compatible with Windows NT 4.0.
 


Any idea?

We're close to succeed (I hope) ........

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, 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.078 seconds in which 0.033 seconds were spent on a total of 14 queries. Zlib compression enabled.

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