Making Shortcuts NON-Tracking
Keywords: shortcut tracking
For any of you who are copying start menus or .lnk files around, the following will make any shortcuts non
tracking (i.e. it will run from the drive letter that it shows as opposed to the UNC to which it was created
at birth. The non tracking is accomplished at the end of the utility below where the BinaryWrite happens.
Debug(@on)
PROGNAME="NoSearch v1.0"
MSG=""
ERRMSG="%PROGNAME% Error"
MYDIR=DirHome()
if %param0%!=0 then goto PASTHELP
:HELPINFO
MSGL1="%@TAB%NoSearch turns off Automatic Shortcut Tracking on
shortcuts%@CRLF%%@CRLF%"
MSGL2="USAGE:%@CRLF%%@TAB%NoSearch.exe [TARGET] [/S] [/H]
%@CRLF%where:%@CRLF%"
MSGL3="%@TAB%TARGET : Path to TARGET Directory%@CRLF%"
MSGL4="%@TAB%%@TAB%if not specified then Current Directory is searched.%@CRLF%"
MSGL5="%@TAB%/S : Recurse Subdirectories below TARGET%@CRLF%"
MSGL6="%@TAB%/H : Include Hidden Files on TARGET%@CRLF%"
For i=1 to 6
MSG=StrCat(MSG,MSGL%i%)
next
Message(PROGNAME,MSG)
exit
:PASTHELP
For i=1 to %param0%
if StrScan(PARAM%i%,"/",1,@FWDSCAN)!=0 then CMDLINE=StrCat(CMDLINE,@TAB)
if StrScan(PARAM%i%,":\",2,@FWDSCAN)==2 then CMDLINE=StrCat(CMDLINE,@TAB)
CMDLINE=StrCat(CMDLINE,PARAM%i%," ")
;;The above rocket science converts the space delimited command line to a
;; tab delimited command line, but leaves spaces where they might be dirnames
next
;;the following rocket science decodes the command line allowing spaces in dirnames,
;; as well as handling UNCs, and ignoring spurious switches.
;;(think about it for a minute before you mess around here )
For i=2 to ItemCount(CMDLINE,@tab)
THISPARAM=StrTrim(ItemExtract(i,CMDLINE,@tab))
if StrIndexNC(THISPARAM,"/S",0,@fwdscan)!=0
RECURSE=@TRUE
Continue
endif
if StrScan(THISPARAM,"/",1,@FWDSCAN)==0 ;ie is not a switch
DO_DIR=THISPARAM
endif
next
if !IsDefined(DO_DIR)
DO_DIR=DirGet() ;if not defined then cwd
endif
lasterror()
DO_DRIVE=StrSub(DO_DIR,1,3)
ErrorMode(@off)
DirChange(DO_DRIVE)
ErrorMode(@cancel)
if LASTERROR()!=0
Message(ERRMSG","Could not locate %DO_DRIVE%")
EXIT
endif
ErrorMode(@off)
DirChange(DO_DIR)
ErrorMode(@cancel)
if LASTERROR()!=0
Message(ERRMSG,"%DO_DIR% Does not exist")
EXIT
endif
DO_DIR=DirGet()
AddExtender("wsrch34I.dll")
HNDLE=SrchInit(DO_DIR,"*.lnk","","",24)
While 1
THISFILE=SrchNext(HNDLE)
if THISFILE=="" then Break
FS=FileSize(THISFILE)
BINBUF=BinaryAlloc(FS)
BinaryRead(BINBUF,THISFILE)
BinaryPoke(BINBUF,21,1)
BinaryWrite(BINBUF,THISFILE)
BinaryFree(BINBUF)
Endwhile
Article ID: W13847
Filename: Making Shortcuts Non-Tracking.txt