Jump to content

Making a shortcut to the desktop


Guest Kristof
 Share

Recommended Posts

Guest Kristof

Okay making a shortcut is fairly easy. But how can you program autit to copy a file of make a shortcut to the desktop for an account of which the name is unkown at the time you write the script.

Exmaple:

you install xp and you define the first account to be "user1".

Yuo log on as user1 and then you want a script to copy a file to the desktop. Easy of course:

filecopy("whatever","c:\doc & set\user1\desktop")

but the above does not work whe you define the first account to be "Peter" instead of "user1".

Is there some way to retrieve the first account name (if not it can be specified by quering the user) AND to that sepcific account name in a file copy function or a make shortcut function.

Thanx for reading and helping,

Kristof

Link to comment
Share on other sites

  • Developers

Okay making a shortcut is fairly easy. But how can you program autit to copy a file of make a shortcut to the desktop for an account of which the name is unkown at the time you write the script.

Exmaple:

you install xp and you define the first account to be "user1".

Yuo log on as user1 and then you want a script to copy a file to the desktop. Easy of course:

filecopy("whatever","c:\doc & set\user1\desktop")

but the above does not work whe you define the first account to be "Peter" instead of "user1".

Is there some way to retrieve the first account name (if not it can be specified by quering the user) AND to that sepcific account name in a file copy function or a make shortcut function.

Thanx for reading and helping,

Kristof

<{POST_SNAPBACK}>

Would this work ?

filecopy("whatever","c:\doc & set\" & @UserName & "\desktop")

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

filecopy("whatever","c:\doc & set\" & @UserName & "\desktop")
Never use this way if you can use @UserProfileDir or even better @DesktopDir. Usernames change, directories do not.

The path C:\Documents and Settings\Alexandra.Meier can belong to the user Alexandra.Heimann when she marries. In worst case your script could even write data in the directory of another user. And yes, I've had this once (usernames were in different format) resulting in a lot of work for me since I had to recreate two useraccounts and sort their data into the right directories.

And if you're not logged on as that user there's still a way to get the real profile path from HKLM\Software\Microsoft\Windows NT\CurrentVersion\ProfileList, but it's a bit more work.

Link to comment
Share on other sites

Guest Kristof

Yup, @DesktopDir does the job pretty fine. Didn't knew those @ thingies even existed.

Thank you all for replying and helping out !!!!!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...