Jump to content
Sign in to follow this  
Guest Peter

Filemove with @UserName Macro

Recommended Posts

Guest Peter

Hi,

i've got a small Problem. I had to move a .lnk File from a various User Account to the All User Startmenu Tree. This is my Function. It doesn't work. How to get it work?

If FileExists ("C:\Dokumente und Einstellungen\" & @UserName

"\Startmenü\Programme\Microsoft Word Viewer.lnk") Then

FileMove ("C:\Dokumente und Einstellungen\" & @UserName "\Startmenü\Programme\Microsoft Word Viewer.lnk" , "C:\Dokumente und Einstellungen\All Users\Startmenü\Programme\Microsoft Word Viewer.lnk")

EndIf

Thanks Peter

Share this post


Link to post
Share on other sites
Guest Doxie

I made a test myself, and it worked perfectly.

Almost the same code as you.

This is my code

If FileExists("C:\Documents and Settings\Doxie\Start Menu\Programs\test.lnk") Then
FileMove("C:\Documents and Settings\Doxie\Start Menu\Programs\test.lnk", "C:\Documents and Settings\All Users\Start Menu\Programs\test.ini")
EndIf

Don´t know why its not working for you?

Do you got admin rights when running the script?

Share this post


Link to post
Share on other sites
Jos

Did you Cut&Paste your code ?

There is a typo in this line:

FileMove ("C:\Dokumente und Einstellungen\" & @UserName & "\Startmenü\Programme\Microsoft Word Viewer.lnk" , "C:\Dokumente und Einstellungen\All Users\Startmenü\Programme\Microsoft Word Viewer.lnk")


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Guest Doxie

aah That´s why my code is working, cause i did not use @UserName :D

Share this post


Link to post
Share on other sites
emmanuel

you missed an &:

If FileExists ("C:\Dokumente und Einstellungen\" & @UserName &"\Startmenü\Programme\Microsoft Word Viewer.lnk") Then

FileMove ("C:\Dokumente und Einstellungen\" & @UserName & "\Startmenü\Programme\Microsoft Word Viewer.lnk" , "C:\Dokumente und Einstellungen\All Users\Startmenü\Programme\Microsoft Word Viewer.lnk")

EndIf

you could also use @UserProfileDir.

as they say in the business; the first one's free:

If FileExists (@ProgramsDir & "\Microsoft Word Viewer.lnk") Then
   FileMove (@ProgramsDir & "\Microsoft Word Viewer.lnk" , @ProgramsCommonDir & "\Microsoft Word Viewer.lnk")
EndIf

Check out Macro Referance - Directory. in the ... you guessed it... Helpfile.

edited the code, fixed to @programsdir...

Edited by emmanuel

"I'm not even supposed to be here today!" -Dante (Hicks)

Share this post


Link to post
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
Sign in to follow this  

×