×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

need some help extracting desktop shortcut paths to a table or to excel please
2

need some help extracting desktop shortcut paths to a table or to excel please

need some help extracting desktop shortcut paths to a table or to excel please

(OP)
Hi Everyone,
a little annoying question

we got hit by ransomware, no all computers but since we can have still traces we are going to reformat all computers hhds and upgrade all possibles WiN 7 to Win 10 pro 64bit, so before i do that i will need.

1- go to each computer and run some sort of routine to read from the desktop the shortcuts path, extract them to excel or a table, so i can know later when i install win 10 the needed path for those shortcuts

it is possible to extract that?
can anyone has experimented this before or have a help to share please ?
Thanks a lot

RE: need some help extracting desktop shortcut paths to a table or to excel please

The desktop is just a directory. It is accessible just like any other directory. Its actual location varies with the version of Windows (in Windows 7, you can find it at /users/<user name>/desktop, for example).

To find the directory programmatically, you can use the code shown here: Finding the paths to Windows' special folders in VFP. (The value to pass as the parameter is 16.)

Once you have found the directory, the shortcuts are present as ordinary files.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: need some help extracting desktop shortcut paths to a table or to excel please

(OP)
Hi Mike,
will this function allow me to list all the path name of each desktop shortcut ?

can you please elaborate a little more please, i am a beginner as you know.

i copied that code into a prg file, so then i added to the prg file "set procedure to getspecial,16"
this actually does not show me anything, sorry something i am not doing correct at all.
Thanks

RE: need some help extracting desktop shortcut paths to a table or to excel please

Ernesto,

No, "set procedure to getspecial,16" is quite wrong.

You need to do something like this:

1. Save the code to a PRG. Name it, say, GetSpecial.PRG

2. SET PROCEDURE TO GetSpecial

3. ? GetSpecial(16)

That last line will display the Desktop path on the screen. More likely, you will want to save it to a variable, and then loop through looking for the files within the Desktop. Something like this:

CODE -->

LOCAL ARRAY laFiles(1)
SET PROCEDURE TO GetSpecial
lcDesktop = GetSpecial(16)
lnCount = ADIR(laFiles, lcDesktop + "*.lnk")
? lnCount
FOR lnI = 1 TO lnCount
  ? laFiles(lnI, 1)
ENDFOR 


That will display the names of all the shortcuts on the desktop. Is that you want? Or do you want to get the target that each shortcut points to? If so, that's possible but a little more difficult.

I'm not sure how any of this is going to help you recover from ransomware, but presumably you know what you are doing.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: need some help extracting desktop shortcut paths to a table or to excel please

(OP)
Yes Mikle,
i need to get the names of the shortcut but also the "target that each shortcut points to
Thanks so much

RE: need some help extracting desktop shortcut paths to a table or to excel please

(OP)
Hi Mike
i am running the below prg as follow and what i get is the lnCount value = 0, the laFiles =.F. and lcDesktop = c:\Users\admin.M100\Desktop.
i added the messagebox() to see the values

should be lnCount = 1 ?
Thanks a lot

CODE -->

LOCAL ARRAY laFiles(1)
SET PROCEDURE TO GetSpecial
lcDesktop =GetSpecial(16)
lnCount = ADIR(laFiles,lcDesktop + "*.Ink")
messagebox("see below ")
** ? lnCount
messagebox(lncount)
MESSAGEBOX(lafiles)
MESSAGEBOX(lcDesktop)

FOR lnI = 1 TO lnCount 
 ? laFiles(lnI, 1)   
ENDFOR 

FUNCTION GetSpecial
* Returns the path to one of Windows' "special folders", 
* such as My Documents, Application Data, Program Files, 
* etc.

* Parameters:
* - The folder's CSIDL;
* - A flag to say the folder should be created if it
*   doesn't already exist.

* Returns the path to the specified folder. If the CLSID
* is invalid, or the folder doesn't exist (and the second
* parameter is .F.), returns an empty string.

LPARAMETERS tnFolder, tlCreate

LOCAL lcPath, lnPidl, lnPidlOK, lnFolderOK

#DEFINE MAX_PATH 260
#DEFINE CREATE_FLAG 32768 

* Delcare the API functions
DECLARE LONG SHGetSpecialFolderLocation IN shell32 ;
	LONG Hwnd, LONG lnFolder, LONG @pPidl
DECLARE LONG SHGetPathFromIDList IN shell32 ;
	LONG pPidl, STRING @pszPath
DECLARE CoTaskMemFree IN ole32 LONG pVoid

lcPath = SPACE(MAX_PATH)
lnPidl = 0

* If .T. is passed as second param, we want to create the 
* folder if it doesn't already exist.
IF tlCreate
	tnFolder = tnFolder + CREATE_FLAG
ENDIF 
	
* Get the PIDL
lnPidlOK = SHGetSpecialFolderLocation(0, tnFolder, @lnPidl)

IF lnPidlOK = 0
  * Pidl found OK; get the folder
  lnFolderOK = SHGetPathFromIDList(lnPidl, @lcPath)
  IF lnFolderOK = 1
    * Folder found OK; trim the string at the null terminator
    lcPath = LEFT(lcPath, AT(CHR(0), lcPath) - 1)
  ENDIF 
ENDIF 

* Free the ID List
CoTaskMemFree(lnPidl)

RETURN ALLTRIM(lcPath) 

RE: need some help extracting desktop shortcut paths to a table or to excel please

Hi Ernesto,

Two problems:

First, in this line: lnCount = ADIR(laFiles,lcDesktop + "*.Ink"), you might need to add a backslash to the end of the path in lcDesktop. Change it to:

lnCount = ADIR(laFiles,ADDBS(lcDesktop) + "*.Ink")

Secondly, *.Ink is wrong. It should be *.lnk. The first letter is a lower-case L, not a capital I.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close