Briandr Posted February 25, 2016 Share Posted February 25, 2016 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. Link to comment Share on other sites More sharing options...
AutoBert Posted February 25, 2016 Share Posted February 25, 2016 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. Link to comment Share on other sites More sharing options...
Briandr Posted February 25, 2016 Author Share Posted February 25, 2016 (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 February 25, 2016 by Briandr Link to comment Share on other sites More sharing options...
rudi Posted February 25, 2016 Share Posted February 25, 2016 Hello. 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? 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! Link to comment Share on other sites More sharing options...
Briandr Posted February 25, 2016 Author Share Posted February 25, 2016 (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 February 25, 2016 by Briandr Link to comment Share on other sites More sharing options...
rudi Posted February 25, 2016 Share Posted February 25, 2016 Sorry, but I definitely miss completely, what exactly is your goal Earth is flat, pigs can fly, and Nuclear Power is SAFE! Link to comment Share on other sites More sharing options...
Briandr Posted February 25, 2016 Author Share Posted February 25, 2016 (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 February 25, 2016 by Briandr Link to comment Share on other sites More sharing options...
rudi Posted February 25, 2016 Share Posted February 25, 2016 Hi Where will the EXE be located? (on a stick, on a local drive, on a network drive, sent by email, whatsoever) when will that script be executed? 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! Link to comment Share on other sites More sharing options...
rudi Posted February 25, 2016 Share Posted February 25, 2016 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! Link to comment Share on other sites More sharing options...
Briandr Posted February 25, 2016 Author Share Posted February 25, 2016 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 Link to comment Share on other sites More sharing options...
Briandr Posted February 25, 2016 Author Share Posted February 25, 2016 (edited) It works for the current user, but it does not run against the other user profiles on the device. #RequireAdmin FileInstall("Printers.url", @ScriptDir & "\Printers.url", 1) FileCopy(@ScriptDir & "\Printers.url" & @FavoritesCommonDir) I will keep digging but I thought this would work. Edited February 25, 2016 by Briandr Link to comment Share on other sites More sharing options...
rudi Posted February 25, 2016 Share Posted February 25, 2016 (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 February 25, 2016 by rudi Earth is flat, pigs can fly, and Nuclear Power is SAFE! Link to comment Share on other sites More sharing options...
Briandr Posted February 25, 2016 Author Share Posted February 25, 2016 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. Link to comment Share on other sites More sharing options...
Briandr Posted February 25, 2016 Author Share Posted February 25, 2016 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. Link to comment Share on other sites More sharing options...
AutoBert Posted February 25, 2016 Share Posted February 25, 2016 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. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now