Page 2 of 2 <12
Topic Options
#171012 - 2006-12-04 11:10 PM Re: IF...ENDIF Script help please [Re: vitaly91]
Benny69 Offline
Moderator
*****

Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
I think you have answered your own question, now all you need to do is modify your code to reflect what you have just defined.


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

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

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

This is what I had all along... Yet it doesn't work! No idea why!

PHP:
if ingroup("ChicagoMM") 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") endif if ingroup("LansingMM") WshShortCut("%userprofile%\desktop\MicroMainXM.lnk","D:\Citrix MicroMain\Lansing Mall\micromainxm.mde") WshShortCut("%userprofile%\desktop\xmREPORT.lnk","D:\Citrix MicroMain\Lansing Mall\xmreport.mde") endif if ingroup("Test_LansingMallMM") 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") 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

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

Registered: 2001-06-05
Posts: 22346
Loc: OK
just like I said 10 replies ago.
this won't work:
Code:
...
        WshShortCut("%userprofile%\desktop\xmREPORT.lnk","D:\Citrix MicroMain\Chicago\xmreport.mde")
...
        WshShortCut("%userprofile%\desktop\xmREPORT.lnk","D:\Citrix MicroMain\Lansing Mall\xmreport.mde")
...
        WshShortCut("%userprofile%\desktop\xmREPORT.lnk","D:\Citrix MicroMain\Test Lansing Mall\xmreport.mde")


if you want more than 2 shortcuts, change the filenames. right?
_________________________
!

download KiXnet

Top
#171018 - 2006-12-04 11:28 PM Re: IF...ENDIF Script help please [Re: vitaly91]
Benny69 Offline
Moderator
*****

Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
one thing i can see is that in each of your wshshortcut() statments you have the %userprofile% inside the quotes, it should be outside like this:
Code:
WshShortCut(%USERPROFILE%+"\desktop\MicroMainXM.lnk","D:\Citrix MicroMain\Chicago\micromainxm.mde")

then modify each one to reflect this change.
_________________________
Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta)

Top
#171034 - 2006-12-05 03:30 AM Re: IF...ENDIF Script help please [Re: Benny69]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11628
Loc: CA
vitaly,

What I think you're missing and that Jooel has tried to point out a few times now is that your links , even though they point to a different location, they are not named different.


i.e. xmREPORT.lnk

You can't have 3, 6, 9, 12 or any other number of "different" links if they are the SAME name. The only thing that happens is that you end up with your xmREPORT.lnk link that now points to the location of the last time it was written to.

i.e.


1 Check If InGroup(1) write xmREPORT.lnk to c:\temp
2 Check If InGroup(2) write xmREPORT.lnk to c:\temp\big
3 Check If InGroup(3) write xmREPORT.lnk to c:\temp\downtown

You end up with 1 link that now points to c:\temp\downtown no matter how many times you run it.

You have to have a different name for each possible combination of links.

So you could have:
xmREPORT(1).lnk
xmREPORT(2).lnk
xmREPORT(3).lnk

xmREPORT(Canada).lnk
xmREPORT(Hungary).lnk
xmREPORT(Spain).lnk

etc.... and that would work just fine. But you can't have 3 shortcuts named the same: xmREPORT.lnk

Top
#171035 - 2006-12-05 04:07 AM Re: IF...ENDIF Script help please [Re: NTDOC]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
sorry, late to the party...

The duplicate shortcuts was my whole point of the if exists statements. He should have been seeing "Already Exists" when running the script. Oh well


Edited by Allen (2006-12-05 04:08 AM)

Top
#171038 - 2006-12-05 06:21 AM Re: IF...ENDIF Script help please [Re: Allen]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11628
Loc: CA
I understand Allen, but apparently he wasn't. So just thought I would drag it out and put in in simpler terms.
Top
#171061 - 2006-12-05 04:46 PM Re: IF...ENDIF Script help please [Re: NTDOC]
vitaly91 Offline
Fresh Scripter

Registered: 2006-12-01
Posts: 12
I understand that. And several posts ago I put this up for discussion:

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



But, as I was told, this isn't quite correct either... So I think at this point I am lost!

Should I remove "Already Exists" parts and just make it this way:

PHP:
if ingroup("Test_LansingMallMM") if exist("%userprofile%\desktop\TestLansingMicroMainXM.lnk")=0 $=WshShortCut("%userprofile%\desktop\TestLansingMicroMainXM.lnk","D:\Citrix MicroMain\Test Lansing Mall\micromainxm.mde") endif if exist("%userprofile%\desktop\TestLansingxmREPORT.lnk")=0 $=WshShortCut("%userprofile%\desktop\TestLansingxmREPORT.lnk","D:\Citrix MicroMain\Test Lansing Mall\xmreport.mde") endif endif


Edited by vitaly91 (2006-12-05 04:49 PM)

Top
#171067 - 2006-12-05 06:38 PM Re: IF...ENDIF Script help please [Re: vitaly91]
vitaly91 Offline
Fresh Scripter

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

I think the way I posted in my previous message works!!! I just tested it and it put 6 shortcuts on the desktop (test user is in all 3 groups).

I would like to thank you ALL for all your help and patience!! \:\)

Top
#171082 - 2006-12-06 03:18 AM Re: IF...ENDIF Script help please [Re: vitaly91]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11628
Loc: CA
Good glad to hear you got it working.

Let me point out a minor item though.

Using just a $ to hold your variable is quite legal and I think I'm one of the few that buck using it. As you're scripts get bigger and when you need to go edit them and you try to go find and change $ Guess what! You're going to have an extremely difficult time finding and replacing or updating that var or line of code after the var because EVERY single var also has to have a $

It is my recommendation to always use some type of meaningful name for your var. $Nul, $RC, $HKLMR, $OldUsers, $NewLink, etc....

Then you can easily find and update code much easier and others that come along after you also have a much easier time updating the scripts.

Also, for a production script you should COMMENT your code at least to some degree so that later on you know what is happening, or again, if someone else new has to modify your code because you're out sick or have left the Company, then it will be easier for them as well.

.

Top
#171242 - 2006-12-08 05:49 PM Re: IF...ENDIF Script help please [Re: vitaly91]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
IF Exist()=0 is pretty weird way imo to put the code.
Way I put it is
Code:
If Exist()
  ? "It Exists!!"
Else
  ? " It's Gone!!"
EndIf


Or

Code:
If Not Exist()
  ? "It's Gone!!"
Else
  ? "It Exists!!"
EndIf

Not that your way is wrong though....


Edited by apronk (2006-12-08 05:50 PM)

Top
#171244 - 2006-12-08 06:16 PM Re: IF...ENDIF Script help please [Re: Arend_]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
hmm... I remember someone telling the same thing about my code way back...
_________________________
!

download KiXnet

Top
#171260 - 2006-12-08 08:44 PM Re: IF...ENDIF Script help please [Re: Lonkero]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
Quote:
IF Exist()=0 is pretty weird way imo to put the code


Agreed. Mainly I did it that way so that this fellow could "see" what the code is doing.... Jooel may remember (as he made a comment about it years ago), I used to be the "NOT" king. Funny how that has totally gone away.

Top
#171261 - 2006-12-08 09:05 PM Re: IF...ENDIF Script help please [Re: Allen]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
The prob with putting the =0 on the end is that some may not read the entire line and infer the opposite. If equating with zero, I prefer to see it up front.

If 0 = Exist()

Kinda smacks you between the eyes so you notice.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#171262 - 2006-12-08 09:28 PM Re: IF...ENDIF Script help please [Re: Les]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11628
Loc: CA
Too bad Shawn is not around anymore. He once showed and explained an example where the If 1= was better in some instances.
Alas, I don't recall the details and example

.

Top
#171266 - 2006-12-08 10:45 PM Re: IF...ENDIF Script help please [Re: NTDOC]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
well, cases when the function does not return integers but say booleans or strings, results may be unexpected when your equation is "reversed"
_________________________
!

download KiXnet

Top
Page 2 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.073 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