Briandr

problem using filecopy

15 posts in this topic

FileInstall("Printers.url", @ScriptDir & "\Printers.url", 1)
FileCopy(@ScriptDir & "\Printers.url", "C:\users\' & @UserName & '\Favorites\")

Hi,

I am trying to copy a URL and while the code does give any errors when compiled it is not working. Anyone have any ideas to fix? Also, would there be a way to run this once against all existing users because as it would stand right now this would have to be run as part of AD logon script.

Thanks.

Share this post


Link to post
Share on other sites



You have a problem with your quotationmarks, see my example:

; This will install the file C:\Test.bmp to the script location.
FileInstall("C:\Program Files\AutoIt3\Examples\GUI\Torus.png", @ScriptDir & "\Torus.png",1)
FileCopy(@ScriptDir & "\Torus.png", "C:\users\" & @UserName & "\Favorites\",8)
ShellExecute("C:\users\" & @UserName & "\Favorites\Torus.png")

it works.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Thanks for noticing the quotation mark error. Ideal situation would be for this to run against all existing users on a device. just not current user. Is that possible? Is there something like @allusers in addition to @username?

Edited by Briandr

Share this post


Link to post
Share on other sites

Hello.

 

  1. Use Fileinstall() to directly save a copy where you finally need it: Propably the script is run from some network share, where regular users do *NOT* have write access?
  2. Use autoit macros, whereever possible. Here: @FavoritesDir

 

FileInstall("printers.url",@FavoritesDir & "\printers.url",1) ; 1 = overwrite

 

Regards, Rudi.


Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

The script won't be run from a network share. Not all users will be on domain. Is there a way with @FavoritesCommonDir or something similiar so when this run all user profiles have their favorites folder up dated?

Edited by Briandr

Share this post


Link to post
Share on other sites

Sorry, but I definitely miss completely, what exactly is your goal :'(


Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Sorry, I think you were replying and I was editing my post and the lines got crossed. Simply update favorites directory for all users on a device, if possible. Will @FavoritesCommonDir work? This is what I am looking for assuming it will work as coded.

 

FileInstall("Printers.url", @ScriptDir & "\Printers.url", 1)
FileCopy(@ScriptDir & "\Printers.url" & FavoritesCommonDir)

 

Edited by Briandr

Share this post


Link to post
Share on other sites

Hi

 

  1. Where will the EXE be located? (on a stick, on a local drive, on a network drive, sent by email, whatsoever)
  2. when will that script be executed?
  3. How to you want to provide updates? As the "printers.url" is fixed compiled into your EXE, you will need to recompile it each and every time, something changes?

 

Please sketch your envirionment, Thanks.

 

REgards, Rudi.


Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Share this post


Link to post
Share on other sites

Hi again.

 

Q: Will @FavoritesCommonDir work

A: Yes, but admin rights will be required.

 

REgards, Rudi.


Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Share this post


Link to post
Share on other sites

That is quite alright because we #RequireAdmin. I appreciate the forward thinking but just to answer your questions:

1. Non changing static URL

2. Altiris or LANDesk will push it out if needs to be updated

3. You got me thinking about if/when it will be updated. I have something in mind. 

I just want to think about this a little more. 

Thanks again

 

 

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Hi again.

You didn't answer, where the EXE is, when it's going to be executed! (local disk, stick, ...)

Google for "process monitor", get it run. Unselect everything but "file access" (icon bar). Set a filter for "Category = write" and "result -IS-NOT- success".

 

Start SciTE "run as administrator", load and run this script:

 

#RequireAdmin

$DestFile=@FavoritesCommonDir & "\MyFile.txt"
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $DestFile = ' & $DestFile & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug ConDosole

$result=fileinstall("MyFile.txt",$DestFile,1)
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $result = ' & $result & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console

 

Edited by rudi

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Share this post


Link to post
Share on other sites

Hi again as well,

I did answer where it would be hosted on a desktop management system such as Altiris or LANDesk sitting in a dmz. A policy within one of those respective systems will run the job either once or on a schedule. I am sorry if the course of the rapid fire postings you may have missed the post.  If I try other macros for users such as @DesktopCommonDir no issues whatsoever. Works perfectly fine. Let me try running this with ProcessExplorer. I also thought there was an issue @FavoritesCommonDir, but that was with an older version of AutoIT. Hope this helps and I hope our lines don't keep getting crossed.

Share this post


Link to post
Share on other sites

Appreciate the help today from folks, but I got nothing. The file came back empty. There was no errors in it. Just curious if you or anyone else tried a quick test. I don't think this will work, but I concede I could be 100% wrong.

Share this post


Link to post
Share on other sites

I think there's a bug, because @FavoritesCommonDir and @FavoritesDir writing  to same Path. So you have to write the path manualy, my example from #2 changed:

; This will install the file C:\Test.bmp to the script location.
FileInstall("C:\Program Files\AutoIt3\Examples\GUI\Torus.png", @ScriptDir & "\Torus.png",1)
FileCopy(@ScriptDir & "\Torus.png", "C:\users\Public\Favorites\",8)
ShellExecute("C:\users\Public\Favorites\Torus.png")

Maybe @Jos has a better workaround. 

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