Page 1 of 1 1
Topic Options
#187393 - 2008-04-30 03:54 PM Wildcards in IF statement
cwhitmore Offline
Starting to like KiXtart

Registered: 2001-05-23
Posts: 102
Loc: Austin, Texas, USA
I'd like to check whether a shortcut exists in the Startup Menu of each user and delete it if it does.
Something like this:

If Exist('C:\Documents and Settings\%username%\Start Menu\Programs\Startup\StaffTracker*.*')
Del ('C:\Documents and Settings\%username%\Start Menu\Programs\Startup\StaffTracker*.*')
Endif

Is the wildcard syntax correct for the If Exist? If so, how do I transfer the "real" name of the StaffTracker*.* to the Del statement?

Top
#187394 - 2008-04-30 04:19 PM Re: Wildcards in IF statement [Re: cwhitmore]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4572
Loc: USA
This should work, but I have seen times when it didn't work as I expected.

To get around it, you could use the builtin DIR to loop through the files using Instr() to see if the name you are looking for is in the filename. You could also use DIRPLUS() (and instr) which is found in the UDF Section.
_________________________
(... better days ahead)

Top
#187395 - 2008-04-30 04:24 PM Re: Wildcards in IF statement [Re: Allen]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4572
Loc: USA
Something like

untested
$dir="C:\TEMP"
$FileName = Dir($dir)
While $FileName <> "" and @ERROR = 0
? $FileName
if instr($filename,"StaffTracker")
;del $dir + "\" + $filename
endif
$FileName = Dir() ; retrieve next file
Loop
_________________________
(... better days ahead)

Top
#187396 - 2008-04-30 04:55 PM Re: Wildcards in IF statement [Re: Allen]
cwhitmore Offline
Starting to like KiXtart

Registered: 2001-05-23
Posts: 102
Loc: Austin, Texas, USA
Allen,
Thanks for the script. I tried it, but it still doesn't work. I even put in the actual file name StaffTracker.web.url, but it won't delete it.
(BTW - I did take out the ; in front of del and changed the "C:\TEMP" to "C:\Documents and Settings\%username%\Start Menu\Programs\Startup")

What else could be causing the problem?

Top
#187397 - 2008-04-30 05:05 PM Re: Wildcards in IF statement [Re: cwhitmore]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4572
Loc: USA
Does the filename show up on the screen when it going through the files?

Put @serror and/or @result on the lines following the del and see what it tells you.
_________________________
(... better days ahead)

Top
#187401 - 2008-04-30 06:16 PM Re: Wildcards in IF statement [Re: Allen]
cwhitmore Offline
Starting to like KiXtart

Registered: 2001-05-23
Posts: 102
Loc: Austin, Texas, USA
Allen,
Turns out that the problem is with VMware. I was running a XP Pro virtual machine on my Vista box, but the script wasn't running at all. After I logged into my laptop the script works fine.
Sorry for wasting yours time.

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 2220 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.064 seconds in which 0.032 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