Sign in to follow this  
Followers 0
GeekyITGuy

Trying to copy file to folder in Users\<username>

6 posts in this topic

Hi,

I am trying to use FileCopy to copy a file from the network to PCs in the following location C:\Users\<currently logged in user>\IPViewer.

If I actually put the username in the command eg. FileCopy ("\\Server\Share\File", "C:\Users\Bob\IPViewer", 1) this works, what I want to do is get the username of the person logged in and use that.

I have tried the following already

"C:\Users\@Username\IPViewer" - no good

"C:\Users\%username%\IPViewer" - no good

I tried creating a variable to do the same ie;

$Login = @UserName or $Login = %username% - then use the variable in the target location C:\Users\$Login\IPViewer - but still no good.

Can anyone help please?

Many Thanks in advance!

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hi,

try:

FileCopy ("\\Server\Share\File", "C:\Users\" & @UserName & "\IPViewer", 1)

or

$user = EnvGet ("username")

FileCopy ("\\Server\Share\File", "C:\Users\" & $user & "\IPViewer", 1)

;-))

Stefan

Edited by 99ojo

Share this post


Link to post
Share on other sites

Wow that was quick!

Thank-you very much for your help, it worked! I have been trying to do this from yesterday evening :(

I have only just started using AutoIt but so far I am loving it!

Thanks again 99ojo.

Share this post


Link to post
Share on other sites

Hi,

you're welcome.

Just for future: Read the helpfile, read the helpfile and once again read the helpfile. ;-))))))

Have a look at the macro functions, starting with @.

Have a look at functions and user defined functions.

Use search in helpfile and on forum. If you have further problems, come back and post.

;-))

Stefan

Share this post


Link to post
Share on other sites

Thanks for the advice,

I did spend quite a while on the forums and the help file but couldnt see where it shows you about enclosing the macro in & &.

Would you be kind enough to tell me where I can find further information on this? I dont have a programming background and would like to learn as I go, so forgive me if this seems a bit of a basic question!

Cheers!

Share this post


Link to post
Share on other sites

Hi,

sorry if my answer sounds a little bit hard.

Have a look into helpfile:

- Introduction

- FAQ

- Tutorials

- Language Reference

- Gui Reference

and most of the question will become clear.

As i mentioned, if you have further problems or questions, come back......

;-))

Stefan

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  
Followers 0