Page 1 of 2 12>
Topic Options
#170917 - 2006-12-01 10:17 PM IF...ENDIF Script help please
vitaly91 Offline
Fresh Scripter

Registered: 2006-12-01
Posts: 12
Guys I have a following script:

if ingroup("Group1")
WshShortCut("%userprofile%\desktop\icon1.lnk","D:\Group1\app1.mde")
WshShortCut("%userprofile%\desktop\icon2.lnk","D:\Group1\app2.mde")
endif

if ingroup("Group2")
WshShortCut("%userprofile%\desktop\icon1.lnk","D:\Group2\app1.mde")
WshShortCut("%userprofile%\desktop\icon2.lnk","D:\Group2\app2.mde")
endif

if ingroup("Group3")
WshShortCut("%userprofile%\desktop\icon1.lnk","D:\Group3\app1.mde")
WshShortCut("%userprofile%\desktop\icon2.lnk","D:\Group3\app2.mde")
endif

function WshShortCut($path,$targetpath,optional $arguments,optional $startdir,optional $iconpath,optional $style)
dim $shell,$shortcut
$shell=createobject("wscript.shell")
if $shell
$shortcut=$shell.createshortcut($path)
if $shortcut
$shortcut.targetpath=$targetpath
if $arguments
$shortcut.arguments=$arguments
endif
if $startdir
$shortcut.workingdirectory=$startdir
endif
if $iconpath
$shortcut.iconlocation=$iconpath
endif
if $style
$shortcut.windowstyle=$style
endif
$shortcut.save
$shortcut=0
endif
$shell=0
endif
exit @error
endfunction

What I am trying to accomplish is for this script to check user's group membership at logonn and "publish" all appropriate icons for him. So if a user belongs to Group1 only, he gets only those icons. But if a user belongs to Group1 AND Group3, he gets icons for Group1 AND Group3.
At the moment it appears to only give him one set of icons.
Any ideas?

P.S. I have posted this couple of days ago, but now I cant find the thread and even had to re-register for the forums. Not sure what happened.

Thank you in advance for all your help!


Edited by vitaly91 (2006-12-01 10:34 PM)

Top
#170918 - 2006-12-01 10:29 PM Re: IF...ENDIF Script help please [Re: vitaly91]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
While not 100% nececessary, there is a more complete version of WSHShortcut found here:
http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Board=7&Number=84115

Aside from that, the only thing I see that is jumping out out me is that you have if ingroup("group2") twice.

Top
#170919 - 2006-12-01 10:37 PM Re: IF...ENDIF Script help please [Re: Allen]
vitaly91 Offline
Fresh Scripter

Registered: 2006-12-01
Posts: 12
Oh.. That was a typo! I fixed it to be Group3, as it is in my script! Thank you!

Would it make a difference if I have a newer version of WSHShortcut?

Top
#170920 - 2006-12-01 10:45 PM Re: IF...ENDIF Script help please [Re: vitaly91]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11628
Loc: CA
Please use the CODE tags when posting to preserve the formatting of your code.

The 9th icon from the left with " marks on it.

It makes it much easier to read and comment on your code.

Thanks

Top
#170921 - 2006-12-01 11:07 PM Re: IF...ENDIF Script help please [Re: vitaly91]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
Try this to see if it helps find the problem. (untested)
Code:
 
if ingroup("Group1")
  if exist("%userprofile%\desktop\icon1.lnk")=0
    $=WshShortCut("%userprofile%\desktop\icon1.lnk","D:\Group1\app1.mde")
    ? @serror
  else
    ? "Already Exists"
  endif
  if exist("%userprofile%\desktop\icon2.lnk")=0
    $=WshShortCut("%userprofile%\desktop\icon2.lnk","D:\Group1\app2.mde")
    ? @serror
  else
    ? "Already Exists"
  endif
endif

if ingroup("Group2")
  if exist("%userprofile%\desktop\icon1.lnk")=0
    $=WshShortCut("%userprofile%\desktop\icon1.lnk","D:\Group1\app1.mde")
    ? @serror
  else
    ? "Already Exists"
  endif
  if exist("%userprofile%\desktop\icon2.lnk")=0
    $=WshShortCut("%userprofile%\desktop\icon2.lnk","D:\Group1\app2.mde")
    ? @serror
  else
    ? "Already Exists"
  endif
endif

if ingroup("Group3")
  if exist("%userprofile%\desktop\icon1.lnk")=0
    $=WshShortCut("%userprofile%\desktop\icon1.lnk","D:\Group1\app1.mde")
    ? @serror
  else
    ? "Already Exists"
  endif
  if exist("%userprofile%\desktop\icon2.lnk")=0
    $=WshShortCut("%userprofile%\desktop\icon2.lnk","D:\Group1\app2.mde")
    ? @serror
  else
    ? "Already Exists"
  endif
endif

Top
#170922 - 2006-12-01 11:17 PM Re: IF...ENDIF Script help please [Re: NTDOC]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Quote:
The 9th icon from the left with " marks on it

Actually, that would give you quote blocks. The 11th with <? on it gives you code tags.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#170923 - 2006-12-01 11:22 PM Re: IF...ENDIF Script help please [Re: Les]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11628
Loc: CA
No that's the PHP tags. The # sign should be the normal UBB CODE tags.

Sorry for the confusion.

9th icon [ quote ][ /quote ]
10th icon [ code ][ /code ]
11th icon [ php ][ /php ]

You want to normally use the 10th one [ code ][ /code ]

Top
#170985 - 2006-12-04 05:29 PM Re: IF...ENDIF Script help please [Re: Allen]
vitaly91 Offline
Fresh Scripter

Registered: 2006-12-01
Posts: 12
Allen,

Thank you for your help!

Here's an issue that I see with your example. And it actually is probably my fault for not discribing situation quite correctly. In your script, you are checking (if understand this right) to see if there is an icon in a user's profile called "icon1.lnk" If icon exists, it skips it and goes to the next icon, if it does not, it puts the icon on. However, it appears that between Groups 1 and 2 it would check for the icon, since it already exists from the 1st Group, it will skip it in case of Group 2 and never put another icon on. I hope I make sense here.
Am I reading this right or am I missing something?

Again, thank you for the help!

Top
#170987 - 2006-12-04 07:00 PM Re: IF...ENDIF Script help please [Re: vitaly91]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11628
Loc: CA
As described for what you want Allens' script should do what you wanted.

It checks all 3 groups every time and runs the shortcut UDF for each group if the user is a member.
 
If something is not working as expected then make sure the user is in the specified groups and / or remove the KiXtart cache (/f switch) and test again.
 

Top
#170995 - 2006-12-04 07:42 PM Re: IF...ENDIF Script help please [Re: NTDOC]
vitaly91 Offline
Fresh Scripter

Registered: 2006-12-01
Posts: 12
NTDOC,

We dont have /f switch. To run the script we just use:

Call "c:\scripts\kix\kix32" "c:\scripts\myscript.kix"

We have this in logon script.

Yet, Allen's script does not do what I am trying to achieve.

And again, lets assume user has never logged on to this server. If a user is on Group1, his script would create check for icon in user's profile and then add the icon. Then it will continue to see if user is in Group2. If he is, it will look to see if the icon is in his profile. In our case, it already is (because user is in Group1). And so it will skip it. And that will happen to all of them after Group1 part.
Also, maybe this is where confusion is, Allen's script points to the same folder on D: (D:\Group1\..) In our case, there are corresponding folders to each group on D: that have links for that particular group. So it should be going there and not into the same folder as Group1. It could be that this is just a "typo" on Allen's part.

Am I understanding this correctly?

Top
#170996 - 2006-12-04 07:58 PM Re: IF...ENDIF Script help please [Re: vitaly91]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
My code is an example. I have no idea how your environment is setup. \:D You will have to modify it so that it works for you.

The way it is written, it should check each group. You will need to modify the code properly to point/create the correct icons. Then, If they are in all three groups and have never run the script before, they should have 6 new icons.

Is that not what you want?

Top
#171000 - 2006-12-04 09:25 PM Re: IF...ENDIF Script help please [Re: Allen]
vitaly91 Offline
Fresh Scripter

Registered: 2006-12-01
Posts: 12
Allen,

Yes. This is what I want and I have modified it. However, it doesn't work.
Here's what I have now using your help:

PHP:
if ingroup("ChicagoMM") if exist("%userprofile%\desktop\MicroMainXM.lnk")=0 $=WshShortCut("%userprofile%\desktop\MicroMainXM.lnk","D:\Citrix MicroMain\Chicago\micromainxm.mde") ? @serror else ? "Already Exists" endif if exist("%userprofile%\desktop\xmREPORT.lnk")=0 $=WshShortCut("%userprofile%\desktop\xmREPORT.lnk","D:\Citrix MicroMain\Chicago\xmreport.mde") ? @serror else ? "Already Exists" endif endif if ingroup("LansingMM") if exist("%userprofile%\desktop\MicroMainXM.lnk")=0 $=WshShortCut("%userprofile%\desktop\MicroMainXM.lnk","D:\Citrix MicroMain\Lansing Mall\micromainxm.mde") ? @serror else ? "Already Exists" endif if exist("%userprofile%\desktop\xmREPORT.lnk")=0 $=WshShortCut("%userprofile%\desktop\xmREPORT.lnk","D:\Citrix MicroMain\Lansing Mall\xmreport.mde") ? @serror else ? "Already Exists" endif endif if ingroup("Test_LansingMallMM") if exist("%userprofile%\desktop\MicroMainXM.lnk")=0 $=WshShortCut("%userprofile%\desktop\MicroMainXM.lnk","D:\Citrix MicroMain\Test Lansing Mall\micromainxm.mde") ? @serror else ? "Already Exists" endif if exist("%userprofile%\desktop\xmREPORT.lnk")=0 $=WshShortCut("%userprofile%\desktop\xmREPORT.lnk","D:\Citrix MicroMain\Test Lansing Mall\xmreport.mde") ? @serror else ? "Already Exists" endif endif function WshShortCut($path,$targetpath,optional $arguments,optional $startdir,optional $iconpath,optional $style) dim $shell,$shortcut $shell=createobject("wscript.shell") if $shell $shortcut=$shell.createshortcut($path) if $shortcut $shortcut.targetpath=$targetpath if $arguments $shortcut.arguments=$arguments endif if $startdir $shortcut.workingdirectory=$startdir endif if $iconpath $shortcut.iconlocation=$iconpath endif if $style $shortcut.windowstyle=$style endif $shortcut.save $shortcut=0 endif $shell=0 endif exit @error endfunction


Yet, this only puts 2 icons on the desktop. Any ideas?

Top
#171001 - 2006-12-04 09:38 PM Re: IF...ENDIF Script help please [Re: vitaly91]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
you are putting 2 shortcuts on the desktop in the code.
if you want more, change the names.

only one shortcut per filename, right?
_________________________
!

download KiXnet

Top
#171002 - 2006-12-04 10:00 PM Re: IF...ENDIF Script help please [Re: Lonkero]
vitaly91 Offline
Fresh Scripter

Registered: 2006-12-01
Posts: 12
Change what name? MicroMainXM.lnk and xmREPORT.lnk? I can't do that. These are people at different offices that use the same application. I can't really rename links for about 200 offices!! We try to control what they see by having folders on D: for each office. On the back-end, it's a bunch of SQL databases. So each office acceses their database.
Top
#171003 - 2006-12-04 10:15 PM Re: IF...ENDIF Script help please [Re: vitaly91]
Benny69 Offline
Moderator
*****

Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
Hi vitaly91,
You are missing the point that Jooel is making.
In each of your 'If InGroup("Group Name")' statements:
  • "ChicagoMM"
  • "LansingMM"
  • "Test_LansingMallMM"

you are adding the same links (shortcuts).
Code:
  if exist("%userprofile%\desktop\MicroMainXM.lnk")=0
    $=WshShortCut("%userprofile%\desktop\MicroMainXM.lnk","D:\Citrix MicroMain\Test Lansing Mall\micromainxm.mde")
    ? @serror
  else
    ? "Already Exists"
  endif
  if exist("%userprofile%\desktop\xmREPORT.lnk")=0
    $=WshShortCut("%userprofile%\desktop\xmREPORT.lnk","D:\Citrix MicroMain\Test Lansing Mall\xmreport.mde")
    ? @serror
  else
    ? "Already Exists"
  endif

What Jooel is saying, is that if you want the different groups to assign different links (shortcuts), you need to change the specific links in the specific group or you need to add code for the links that you want to add.




Edited by Benny69 (2006-12-04 10:17 PM)
_________________________
Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta)

Top
#171005 - 2006-12-04 10:29 PM Re: IF...ENDIF Script help please [Re: Benny69]
vitaly91 Offline
Fresh Scripter

Registered: 2006-12-01
Posts: 12
Benny,

So if I understand you right, I need to do this:

PHP:
if ingroup("ChicagoMM") if exist("%userprofile%\desktop\ChicagoMicroMainXM.lnk")=0 $=WshShortCut("%userprofile%\desktop\ChicagoMicroMainXM.lnk","D:\Citrix MicroMain\Chicago\micromainxm.mde") ? @serror else ? "Already Exists" endif if exist("%userprofile%\desktop\ChicagoxmREPORT.lnk")=0 $=WshShortCut("%userprofile%\desktop\ChicagoxmREPORT.lnk","D:\Citrix MicroMain\Chicago\xmreport.mde") ? @serror else ? "Already Exists" endif if ingroup("Test_LansingMallMM") if exist("%userprofile%\desktop\TestLansingMicroMainXM.lnk")=0 $=WshShortCut("%userprofile%\desktop\TestLansingMicroMainXM.lnk","D:\Citrix MicroMain\Test Lansing Mall\micromainxm.mde") ? @serror else ? "Already Exists" endif if exist("%userprofile%\desktop\TestLansingxmREPORT.lnk")=0 $=WshShortCut("%userprofile%\desktop\TestLansingxmREPORT.lnk","D:\Citrix MicroMain\Test Lansing Mall\xmreport.mde") ? @serror else ? "Already Exists" endif endif


Is this correct?

Top
#171006 - 2006-12-04 10:48 PM Re: IF...ENDIF Script help please [Re: vitaly91]
Benny69 Offline
Moderator
*****

Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
Sorta but not quite, lets try this:

If a user is in this group "ChicagoMM"
what shortcuts, programs or what ever do you want the user to get?

If a user is in this group "LansingMM"
what shortcuts, programs or what ever do you want the user to get?

If a user is in this group "Test_LansingMallMM"
what shortcuts, programs or what ever do you want the user to get?
_________________________
Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta)

Top
#171007 - 2006-12-04 10:59 PM Re: IF...ENDIF Script help please [Re: Benny69]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Why not just use one InGroup('ChicagoMM','LansingMM','Test_LansingMallMM') statement?
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#171009 - 2006-12-04 11:05 PM Re: IF...ENDIF Script help please [Re: Benny69]
vitaly91 Offline
Fresh Scripter

Registered: 2006-12-01
Posts: 12
If user is in ChicagoMM group, he needs:

PHP:
WshShortCut("%userprofile%\desktop\MicroMainXM.lnk","D:\Citrix MicroMain\Chicago\micromainxm.mde") WshShortCut("%userprofile%\desktop\xmREPORT.lnk","D:\Citrix\MicroMain\Chicago\xmreport.mde") WshShortCut("%userprofile%\desktop\xmEXEC.lnk","D:\Citrix MicroMain\MicroMain Training\xmexec.mde")


If user is in LansingMM group, he needs:

PHP:
WshShortCut("%userprofile%\desktop\MicroMainXM.lnk","D:\Citrix MicroMain\Lansing Mall\micromainxm.mde") WshShortCut("%userprofile%\desktop\xmREPORT.lnk","D:\Citrix MicroMain\Lansing Mall\xmreport.mde")


If user is in Test_LansingMM, he needs:

PHP:
WshShortCut("%userprofile%\desktop\MicroMainXM.lnk","D:\Citrix MicroMain\Test Lansing Mall\micromainxm.mde") WshShortCut("%userprofile%\desktop\xmREPORT.lnk","D:\Citrix MicroMain\Test Lansing Mall\xmreport.mde")


If a user is in 2 or more of these groups, he needs all pertaining shortcuts (unless they are identical of course)

Thank you again for your patience and help!!


Edited by vitaly91 (2006-12-04 11:08 PM)

Top
#171011 - 2006-12-04 11:10 PM Re: IF...ENDIF Script help please [Re: Les]
vitaly91 Offline
Fresh Scripter

Registered: 2006-12-01
Posts: 12
Les,

Problem with using one statement is that as people are added to groups or moved, someone will have to manage all this. Unfortunately, we dont have resources or time to do it. It's much easier to set it up once and then let the script do the rest.

Top
Page 1 of 2 12>


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

Who's Online
0 registered and 874 anonymous users online.
Newest Members
StuTheCoder, M_Moore, BeeEm, min_seow, Audio
17884 Registered Users

Generated in 0.063 seconds in which 0.02 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