Jump to content

Recommended Posts

Posted (edited)

I am trying both FileInstall and FileCopy. I can get it to work if I pick a folder anywhere else that exists, but for some reason if I try to make the path "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp" or @StartupCommonDir, it doesn't create or copy the file there depending on what I try. 

The reason I need to put it here is because I can't run the exe i'm making in the user's context. My remote management tool will only run under the SYSTEM context. So I think this is the best way I can get it to the user's start up folder, as well as without triggering a UAC prompt. 

Anyone have advice? 

I've tried each of the following: 

  • FileInstall("C:\ITScript.exe", "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp", 1)
  • FileInstall("C:\ITScript.exe", @StartupCommonDir, 1)
  • FileCopy("C:\ITScript.exe", "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp")
  • FileCopy("C:\ITScript.exe", @StartupCommonDir)

 

 

Edited by jgq85
Posted

I believe your source location is wrong but I know your destination is incomplete.
I think it should be...

FileInstall("ITScript.exe", @StartupCommonDir & "\ITScript.exe", 1)
Or
FileCopy("ITScript.exe", @StartupCommonDir & "\ITScript.exe", 1)

 

Posted

Specifically, this isn't working because FileCopy and FileInstall expect either the full path to a file or a directory with a trailing backslash. If there isn't a trailing backslash, your directory looks like a file without an extension on the end. If you print any of the directory macros, you'll see that they don't contain a trailing backslash (a pet peeve of mine, but okay).

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts
UI-SimpleWrappers UDF - Use UI Automation more Simply-er
KeePass UDF - Automate KeePass, a password manager
InputBoxes - Simple Input boxes for various variable types

Posted
14 hours ago, 1957classic said:

I believe your source location is wrong but I know your destination is incomplete.
I think it should be...

FileInstall("ITScript.exe", @StartupCommonDir & "\ITScript.exe", 1)
Or
FileCopy("ITScript.exe", @StartupCommonDir & "\ITScript.exe", 1)

 

Hi @1957classic,

Thanks for the reply. I'm compiling the script to exe so does that mean I have to specify the path to the ITScript.exe on the machine I'm compiling from? So that it merges into the exe on the target system? 

Posted

Once compiled, you cannot use any variables in the source path.  Read help file, it clearly states it.  So if the location of the source file varies, you will need to adjust  you script  But you could use a map drive or something similar so you don't have to edit the script for every computer.

Posted
2 minutes ago, Nine said:

Once compiled, you cannot use any variables in the source path.  Read help file, it clearly states it.  So if the location of the source file varies, you will need to adjust  you script  But you could use a map drive or something similar so you don't have to edit the script for every computer.

On the help KB (https://www.autoitscript.com/autoit3/docs/functions/FileInstall.htm) the example is:

FileInstall("C:\Test.bmp", @ScriptDir & "\Test.bmp")

In my case isn't the Test.bmp my ITScript.exe ? Example uses C:\Test.bmp, not just "Test.bmp"

Posted

Let me explain :

1) c:\test.bmp   ==> is an absolute path (the file MUST be located inside c:\)

2) test.bmp ==> is a relative path to the script folder  (it means, that the file MUST be at the same place as the script)

3) m:\test.bmp ==>  where m: is a map drive that relates to any other computer/drive/network that contains the file you want.

I suggest you use the 3rd solution where you can apply the same script to any computer in your environment.

  • 3 weeks later...
Posted

One more point: What you are trying to do is to create a lot of independent copies of the exact same EXE file.

 

Ooooghhh!

 

I'd like to mention, that you place in the @StartupCommonDir a LNK to "one-file-on-a-network-share" for all computers.

 

$WD="\\server\share\Path1\Path2"
$EXE="ITscript.EXE"
$LNK=@StartupCommonDir & "\" & StringTrimRight($EXE,3) & "LNK"
FileCreateShortcut($WD & "\" & $EXE,$LNK,$WD,"","Description what this EXE is doing")

Rudi

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

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...