Jump to content

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


Recommended Posts

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!

Link to comment
Share on other sites

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
Link to comment
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

Link to comment
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!

Link to comment
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

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...