Jump to content

using environment variables in unc path


Recommended Posts

Hello folks,

i´m trying to write my first script using autoit where i want to use an UNC PATH to copy a file from source to destination, but i can´t get it to work. i also searched the wiki - but without any luck.

my script so far:

$myvar = EnvSet("USERPROFILE")

FileCopy( "\\server\folder\file.txt", "$myvar\folder\file.txt" ,9)

:(

Can anybody understand what i´m trying to do?

thx in advance

Link to comment
Share on other sites

First, welcome to the AutoIt forum!

Next you need to remember something very important and true: from now on, your best friend is AutoIt help file!

Now, I suppose the target filename should be $myvar & "\folder\file.txt"where the & is string concatenation.

It's always good to check for error value after a function call :( This way you could have narrowed the issue to "FileCopy returns no error on this but the file isn't copied". And that's much easier for those ready to help than just posting code (whatever simple it may be) and declare "It doesn't work!".

Finally, pleas next time use AutoIt button to bracket your code. It doesn't really matter when only two lines are posted in pain text, but gets really awfull for longer code. This the blue button just below the bold button. Click on it, click Add and then paste your code between the tags.

Have fun.

Edited by jchd

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

my script so far:

$myvar = EnvSet("USERPROFILE")

FileCopy( "\\server\folder\file.txt", "$myvar\folder\file.txt" ,9)

That's very confused.

You want EnvGet() vice EnvSet().

After that you can fix it with what jchd told you about the append operator.

:(

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

First, welcome to the AutoIt forum!

Next you need to remember something very important and true: from now on, your best friend is AutoIt help file!

Now, I suppose the target filename should be $myvar & "\folder\file.txt"where the & is string concatenation.

It's always good to check for error value after a function call :( This way you could have narrowed the issue to "FileCopy returns no error on this but the file isn't copied". And that's much easier for those ready to help than just posting code (whatever simple it may be) and declare "It doesn't work!".

Finally, pleas next time use AutoIt button to bracket your code. It doesn't really matter when only two lines are posted in pain text, but gets really awfull for longer code. This the blue button just below the bold button. Click on it, click Add and then paste your code between the tags.

Have fun.

Hello jchd,

thank you for the quick response. I searched the help file for like 60 minutes for variable declaration and so on but didn´t know the term for my problem in plain english - string concatentation is truly solving this mystery. next time i will try to search harder ;-D.

The next time i post my problem will be a "real one".

greetings

mfdoom

Link to comment
Share on other sites

For AutoIt "basics": Help File > Language Reference is a good start.

Have fun and success!

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

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