Page 1 of 1 1
Topic Options
#149210 - 2005-10-04 09:51 PM If two values exist
plazaai Offline
Fresh Scripter

Registered: 2003-07-25
Posts: 8
I need help writing a script. I need to check for membership in a group and a specific reg key.
If user belongs to group and reg key does not exist then install exe.

if use is not in group do nothing
if user is in group and key exists do nothing

Help Please

Top
#149211 - 2005-10-04 10:01 PM Re: If two values exist
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Here is an example. You should have the latest version of KiXtart 4.50

Code:
Break On
Dim $SO
$SO=SetOption('Explicit','On')
$SO=SetOption('NoVarsInStrings','On')
$SO=SetOption('NoMacrosInStrings','On')
 
If InGroup('MyDomain\MyTestGroup')
If Not KeyExist('HKLM\Software\MyKey')
SHELL 'NOTEPAD.EXE'
EndIf
EndIf


Top
#149212 - 2005-10-05 01:30 AM Re: If two values exist
StarwarsKid Offline
Seasoned Scripter
*****

Registered: 2005-06-15
Posts: 506
Loc: Oregon, USA
(POST REMOVED DUE TO HIJACKING)

Edited by StarwarsKid (2005-10-05 05:24 PM)
_________________________
let the wise listen and add to their learning,
and let the discerning get guidance- Proverbs 1:5

Top
#149213 - 2005-10-05 03:36 AM Re: If two values exist
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Yes it is HiJacking. You should post your own post and reference this one if needed.

Not REQUIRED, but heavily recommended to use these options so that you don't make unknown mistakes in your code. These options will force you to code better overall.

Top
#149214 - 2005-10-07 03:38 PM Re: If two values exist
wagsgt Offline
Fresh Scripter

Registered: 2005-10-07
Posts: 5
If InGroup ("Group")
If Not KeyExist ("HKLM\SOFTWARE\Mykey")
run "%logonserver%\netlogon\site\app.exe"
endif
endif


So this would be correct? It looks at group first then if in group checks for key? But if not in group it skips and doesnt even check for key? BTW the first question was posted for me, Im not "hijacking"

Top
#149215 - 2005-10-07 03:49 PM Re: If two values exist
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
I would leave the domain in the InGroup() as DOC suggests.

Both NOT and KeyExist() are version dependent. What is @KiX?

I find "%logonserver%" to be unreliable and sinfully slow on XP in an AD 2000 environment. I would go with:
Shell '\\domain.tld\netlogon\site\app.exe'
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#149216 - 2005-10-07 05:13 PM Re: If two values exist
wagsgt Offline
Fresh Scripter

Registered: 2005-10-07
Posts: 5
I believe its v4.2.
Top
#149217 - 2005-10-10 05:18 PM Re: If two values exist
wagsgt Offline
Fresh Scripter

Registered: 2005-10-07
Posts: 5
If InGroup ("domain\Group")
If Not KeyExist ("HKLM\SOFTWARE\Mykey")
run "%logonserver%\netlogon\site\app.exe"
endif
endif

Hello, After some testing this seems to be working, does anyone see a reason it would not?

Also is there a way after this install, the target computer can create a txt file that shows is succesfully installed?

Thanks again!!

Top
#149218 - 2005-10-10 05:21 PM Re: If two values exist
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
if not ingroup()
if not exist($somefile)
run or shell "some app"
$=writeprofilestring($somefile,'something','something','something')
endif
endif
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#149219 - 2005-10-10 10:27 PM Re: If two values exist
wagsgt Offline
Fresh Scripter

Registered: 2005-10-07
Posts: 5
Sorry was having some trouble understanding last post. I searched around and found the single line below. That seems to create a file that shows me what user and machine ran the install. But I know im skipping some code. Could someone maybe explain a little more in detail?Thanks!

If InGroup ("domain\Group")
If Not KeyExist ("HKLM\SOFTWARE\Mykey")
run "%logonserver%\netlogon\site\app.exe"
WRITEPROFILESTRING("\\server\folder\Installlog.ini","@fullname","@hostname","@date")
endif

Top
#149220 - 2005-10-11 12:49 AM Re: If two values exist
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Hello wagsgt,


Since you're not the starter of this thread this is considered Hi Jacking. Please start your own thread in either STARTERS or GENERAL forum and put a link to this thread if you like for reference.

That way you can take the discussion into more details if you want without making the original question become lost in detail from the original poster.

Thanks.

Top
#149221 - 2005-10-11 02:56 AM Re: If two values exist
wagsgt Offline
Fresh Scripter

Registered: 2005-10-07
Posts: 5
Hey NTDOC,
The guy that posted this is thread actually posted the first topic for me since I did not know about these forums. Then I got on here also, should I still start a new thread? If so thats not a problem? Thanks!

Top
#149222 - 2005-10-11 03:16 AM Re: If two values exist
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
No that's fine. Don't worry about it. Just remember for future posting on the board.
Top
#149223 - 2005-10-11 03:20 AM Re: If two values exist
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Code:
If InGroup ("domain\Group")
;Checks if the user is in the specific group, if not then the whole section of
;code is skipped
If Not KeyExist ("HKLM\SOFTWARE\Mykey")
;If the key is not found it will launch the application, otherwise it will quit
run "%logonserver%\netlogon\site\app.exe"
 
;WriteProfileString("\\server\folder\Installlog.ini",@fullname,@hostname,@date)
;Need to readup on the WriteProfileString as you can't use it quite like this
EndIf
EndIf


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 641 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.065 seconds in which 0.023 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