Okay, so just so I understand, if I use an exe, any text files added to the project will be discarded. If I build an MSI, any text files included in the project will be available and copied to the installation location. Is that correct?
What if the contents of the text file is a powershell script? Can I access the contents in the exe? If I can call it, can I redirect the contents to a text file on the local filesystem?
How to reference files included in a Forms Project
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Re: How to reference files included in a Forms Project
That's very helpful. So when I reference this file, I use Call-filename_txt. What output does this call give? If I set it to a variable, will the variable contain the contents of the file? Like this:
Or is there another way to do this?
- $textfile = Call-filename_txt
- dan.potter
- Posts: 709
- Last visit: Wed Nov 14, 2018 11:39 am
Re: How to reference files included in a Forms Project
McKenning wrote:That's very helpful. So when I reference this file, I use Call-filename_txt. What output does this call give? If I set it to a variable, will the variable contain the contents of the file? Like this:
Or is there another way to do this?
$textfile = Call-filename_txt
Can you give an example of what you are trying to do? What would the text file contain? Are you trying to get contents of a text file?
Re: How to reference files included in a Forms Project
Here is how to find your file:
- $filepath= Join-Path $myinvocation.PSScriptRoot $myfile
Re: How to reference files included in a Forms Project
Yes, I am trying to get the contents of the text file so that I can update a script that will be called remotely by this project. So I want to do something like this:dan.potter wrote: Can you give an example of what you are trying to do? What would the text file contain? Are you trying to get contents of a text file?
- 1. Click a button to call the remote script.
2. The code in the button will get the contents of the bundled text file and copy it to a file in the filesystem of the executing machine.
3. The code in the button will then copy the file to the filesystem of the remote machine.
4. The code in the button will then call that remote file as a script and have it execute.
5. The output of the remote script will be displayed on the screen for the user.
Re: How to reference files included in a Forms Project
Okay, so the txt file will be dropped when the exe runs and I can see the file at the location above? What is the $myfile variable?jvierra wrote:Here is how to find your file:
$filepath= Join-Path $myinvocation.PSScriptRoot $myfile
Re: How to reference files included in a Forms Project
Include the script as content. Reference it as I posted above:
- filepath= Join-Path $myinvocation.PSScriptRoot $myfile
- Invoke-Command -FilePath $myfile -Computer <remotepc>
Re: How to reference files included in a Forms Project
No - the file will be installed along with the EXE by the installer. It will be in the installation folderMcKenning wrote:Okay, so the txt file will be dropped when the exe runs and I can see the file at the location above? What is the $myfile variable?jvierra wrote:Here is how to find your file:
$filepath= Join-Path $myinvocation.PSScriptRoot $myfile