#170917 - 2006-12-01 10:17 PM
IF...ENDIF Script help please
|
vitaly91
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
|
|
|
|
#170919 - 2006-12-01 10:37 PM
Re: IF...ENDIF Script help please
[Re: Allen]
|
vitaly91
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
|
|
|
|
#170921 - 2006-12-01 11:07 PM
Re: IF...ENDIF Script help please
[Re: vitaly91]
|
Allen
KiX Supporter
   
Registered: 2003-04-19
Posts: 4562
Loc: USA
|
Try this to see if it helps find the problem. (untested)
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
|
|
|
|
#170985 - 2006-12-04 05:29 PM
Re: IF...ENDIF Script help please
[Re: Allen]
|
vitaly91
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
|
|
|
|
#170995 - 2006-12-04 07:42 PM
Re: IF...ENDIF Script help please
[Re: NTDOC]
|
vitaly91
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
KiX Supporter
   
Registered: 2003-04-19
Posts: 4562
Loc: USA
|
My code is an example. I have no idea how your environment is setup. 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
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:
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
|
|
|
|
#171002 - 2006-12-04 10:00 PM
Re: IF...ENDIF Script help please
[Re: Lonkero]
|
vitaly91
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
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).
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)
|
|
Top
|
|
|
|
#171005 - 2006-12-04 10:29 PM
Re: IF...ENDIF Script help please
[Re: Benny69]
|
vitaly91
Fresh Scripter
Registered: 2006-12-01
Posts: 12
|
Benny,
So if I understand you right, I need to do this:
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
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?
|
|
Top
|
|
|
|
#171009 - 2006-12-04 11:05 PM
Re: IF...ENDIF Script help please
[Re: Benny69]
|
vitaly91
Fresh Scripter
Registered: 2006-12-01
Posts: 12
|
If user is in ChicagoMM group, he needs:
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:
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:
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
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
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 874 anonymous users online.
|
|
|