Page 1 of 1 1
Topic Options
#204135 - 2012-01-28 09:29 AM How to execute script s in W7 with the local GPO
yellowdog Offline
Starting to like KiXtart

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

What kind of configuration do I have to do on a W7 workstation in order to execute a kixtart script that is called by local GPO as the users open a session.
The objective is to execute automatically (when the user open a session)a script on a W7 disconnected from the network.

Thanks

Top
#204152 - 2012-01-30 06:04 PM Re: How to execute script s in W7 with the local GPO [Re: yellowdog]
yellowdog Offline
Starting to like KiXtart

Registered: 2005-06-14
Posts: 102
UP !!!!!
Top
#204153 - 2012-01-30 06:11 PM Re: How to execute script s in W7 with the local GPO [Re: yellowdog]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
Is "at computer startup" also fine?
If yes, add an entry in the registry subkey
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run

Top
#204158 - 2012-01-31 10:10 AM Re: How to execute script s in W7 with the local GPO [Re: Witto]
yellowdog Offline
Starting to like KiXtart

Registered: 2005-06-14
Posts: 102
No, I want the script to run at user's logon not at computer startup.
Then.....

Top
#204162 - 2012-01-31 12:15 PM Re: How to execute script s in W7 with the local GPO [Re: yellowdog]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
During user logon, add an entry to
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
Let it start a script on the computer
Check for the environment variable %LOGONSERVER%
Now you should know if the user is logged on to the domain or with cached credentials

Top
#204163 - 2012-01-31 12:19 PM Re: How to execute script s in W7 with the local GPO [Re: yellowdog]
BradV Offline
Seasoned Scripter
****

Registered: 2006-08-16
Posts: 687
Loc: Maryland, USA
If the systems aren't part of a domain, why don't you just start the group policy msc on the local system. Since it isn't connected to a domain, you are only going to see the local computer policy. Select User Configuration, Windows Settings, Scripts, Logon and put your login script there. Is that what you were after, or am I missing something?
Top
#204170 - 2012-01-31 09:47 PM Re: How to execute script s in W7 with the local GPO [Re: Witto]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
 Originally Posted By: Witto

Check for the environment variable %LOGONSERVER%
Now you should know if the user is logged on to the domain or with cached credentials
That has never worked for me.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#204172 - 2012-01-31 11:58 PM Re: How to execute script s in W7 with the local GPO [Re: Les]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Correct.
I'm currently logged on with cached credentials and %logonserver% is filled with the name of one of my DC's so checking it will not work. Pinging a DC would be more reliable. Still not 100% though.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#204173 - 2012-02-01 12:57 AM Re: How to execute script s in W7 with the local GPO [Re: Mart]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
I found this vbs thread...just out of curiosity, does it also display your DC when logged on with cached credentials?

 Code:
$objShell = CreateObject("Wscript.Shell")
$objEnvProcess= $objShell.Environment("PROCESS")

$strLogonServer = Right($objEnvProcess.Item("LogonServer"), -2)

? $strLogonServer

get $

Top
#204175 - 2012-02-01 01:55 PM Re: How to execute script s in W7 with the local GPO [Re: ShaneEP]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Yes, it returned my DC.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#204176 - 2012-02-01 03:23 PM Re: How to execute script s in W7 with the local GPO [Re: Les]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4563
Loc: USA
I found a good article on this... and it appears that %logonmode% worked at one time, but broke at some point. There doesn't seem to be a real good answer for this.

http://us.generation-nt.com/answer/detecting-cached-credentials-nt-2k-xp-03-help-27431502.html

Top
#204181 - 2012-02-01 05:34 PM Re: How to execute script s in W7 with the local GPO [Re: Allen]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
The Kix @LOGONMODE macro also broke some time ago. I've been using a simple workaround for years..

When you are logging in via a live network connection, the netlogon folder is placed first in the system path. If you split the %PATH% variable and element 0 contains "netlogon" you can be reasonably sure that you're on a live connection and not offline/cached.
 Code:
If InStr(Split('%PATH%', ';')[0], 'NetLogon')
  'Live login' ?
EndIf
This might help in this situation. I don't use GPO-based login scripts so can't say for sure.

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

Top
#204184 - 2012-02-01 10:23 PM Re: How to execute script s in W7 with the local GPO [Re: Glenn Barnas]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4563
Loc: USA
Nice find Glenn... barely tested but... here it is in UDF form.

Someone care to verify it works?

if logonmode()
  ? "logonmode"
else
  ? "other mode"
endif
 
function logonmode() $logonmode=iif(InStr(Split('%PATH%', ';')[0], 'NetLogon'),1,0) endfunction

Top
#204185 - 2012-02-02 02:14 AM Re: How to execute script s in W7 with the local GPO [Re: Allen]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
This has been part of our commercial login script for a couple of years now. I know the logic works for legacy scripting, so the test must be for GPO script.

We use this logic to decide if the user's home folder should be mapped manually, most specifically for when a VPN user connects and then wants to run the login script instead of logging in via the VPN.

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

Top
#204186 - 2012-02-02 02:42 AM Re: How to execute script s in W7 with the local GPO [Re: Glenn Barnas]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4563
Loc: USA
It still wouldn't hurt to test it. I might have messed something up. I don't have a machine handy or I would do it myself.
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
0 registered and 519 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.072 seconds in which 0.029 seconds were spent on a total of 13 queries. Zlib compression enabled.

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