Sign in to follow this  
Followers 0
MrBoo

Stuck with $var

5 posts in this topic

Hey folks,

This is probably a really simple one, but I'm struggling and I'd be really grateful if someone could help me out...

I'm making a script that will run on multiple systems. As part of the script, it will copy a file from one location (say: C:\settings-temp\options.xml) to a subfolder of the active user's documents folder (for example: C:\Users\-USERNAME-\Documents\Options\options.xml). The issue is that each system the script needs to run on will have a different active username when the script runs.

I figured $var would probably be useful here...

If I run (as the example in the script reference):

$var = EnvGet("USERPROFILE")
MsgBox(4096, "Path variable is:", $var)

...A Message-box pops-up with the correct path (in this case - C:\Users\Rob)

So, next I tried to use the following:

$var = EnvGet("USERPROFILE")
FileCopy("C:\settings-temp\options.xml","$var\Documents\Options\options.xml", 9)

...Unfortunately it doesn't copy the file, and as far as I can see there's no error code.

Does anyone have an idea of how I can do what I'm trying-to?

Any advice would be fantastic!...

Thanks and regards,

Rob.

Share this post


Link to post
Share on other sites



Just a quick update...

It's sort-of copying the file... Just not to where I need it...

When the script runs it's making a folder on my Desktop - $var\Options\ and putting the file options.xml in there?

Thanks and regards,

Rob.

PS> At the moment the system I'm using is Windows Vista, ideally I need to get this working on XP too.

Share this post


Link to post
Share on other sites

Try

$var = EnvGet("USERPROFILE")
FileCopy("C:\settings-temp\options.xml",$var & "\Documents\Options\options.xml", 9)oÝ÷ ÚÛzÛ^­«­¢+Ù¥±
½Áä ÅÕ½ÐíèÀäÈíÍÑÑ¥¹ÌµÑµÀÀäÈí½ÁÑ¥½¹Ì¹áµ°ÅÕ½Ðì±UÍÉAɽ¥±¥ÈµÀìÅÕ½ÐìÀäÈí½Õµ¹ÑÌÀäÈí=ÁÑ¥½¹ÌÀäÈí½ÁÑ¥½¹Ì¹áµ°ÅÕ½Ðì°ä¤

Share this post


Link to post
Share on other sites

The var concatenation is specified wrong:

FileCopy("C:\settings-temp\options.xml",$var & '\Documents\Options\options.xml", 9)

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

Guys, that's awesome!

Thanks very much indeed for your help. It's working exactly as hoped now!

Thanks again! :D

Rob.

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