power shell not releasing dll handle - powershell

I have a zip file which contains lot of dlls. Using power shell I unzip them and then import one dll to perform some operations. It works for the first time
Expand-ZipArchive "Myzip.zip" #this operation unzip all files
import-module "test.dll" #load the dll from zip file
perform some operations
But when I run it again Expand-ZipArchive fails to replace the dll files because the power shell is still holding it even after the execution. I am getting below error
"The process cannot access the file test.dll because it is being used by another process.\""
The only solution is close the powershell command prompt and then start a new window. But this will not help me in actual production enviornment
I tried to unload the module but still no help. I need to unzip every time because the zip will have new releases
I think I explained the issue in a very bad way. Any suggestions would help

Related

Convert a PowerShell script to exe Including an Exe file into it

I have a few Powershell scripts that I use to copy files and run installations with the required install steps included in the sript, i know how to convert these scripts into exes. I would like to know, how to include the files I am installing with the script in the powershell converted exe?
This utility on github has proven very useful to me:
https://github.com/rzander/PS2EXE
It comes with a pretty straightforward GUI and command-line version, but only works with one PowerShell file.
I have modified a personal version to take multiple files and combine them into one executable. Let me know if you’re interested and I can upload it.
I would like to answer my own question for whom ever come across the same issue or need!
I had the way of doing this all along, but I didn't pay attention to details: For what I required which is to convert a .PS1 script that installs postgresql unattended, to an .exe file including(Postgres enbedded in the exe).
The best tool for this is the "PS1 to EXE" https://gallery.technet.microsoft.com/PS1-To-EXE-Generator-d39e8be2 software,
1. Load your ps1 file, make sure everything is working before hand.
2. Embed the the files you need for the ps1 to work (embed option is on the right column next to the "Options")
Then you can click the convert option
PS: Be sure to have the correct file path.

MATLAB permission denied to access files from C (OS partition)

I created an installer with Installshield for my MATLAB GUI. Installer copies all files of my program to c:/Program files/Program_name. When I run it from shortcut, an error appears that can't overwrite some file. I think this is a permission error because my program is in OS partition. I have some functions like mget , mput and fprintf for some text files in that directory and some times my software download some files from FTP and copy them in discoursed directory.
When you copy some codes that have functions like these and run your code from C:/ (OS partition), you have this problem (without using any installer). I need an automatic solution because this program is going to install on some computers.
How can I solve this problem?
Thanks.
Write to MyDocuments instead (e.g. appdata) - that's the one place where the user is guaranteed to have write permissions.
(Jonas comment. Thank you for your answer)

How can we upload log files from a failed .msi install (Using WiX to create)

We have a problem with our current installer for a browser plugin where a small percent of our users try to install it but the .msi install fails. The issue is we can't get the logs back from them as it is an anonymous download and our QA computers aren't getting this issue. We know they fail as we have log file in JS from before the download and a survey response after saying they tried to install it.
I have searched around but haven't found an answer on how to have an automatic upload of log files on failure of a windows .msi install.
The best solution I have seen is in WiX, we can create a shell script action after the install and then use PowerShell or bitsadmin to try to upload a specific log file from the commandline if we can find it in the temp directory, however this does not seem to be a clean or reliable solution.
Being able to PUT or POST it anywhere would be fine.
Any help is appreaciated.
If you set the MsiLogging property to something like "voicewarmupx", you can later use the property MsiLogFileLocation to get the log file location. This supported in Windows Installer 4.0 and higher.
If a batch file or PowerShell script isn't giving you the programmability you need, you can create a custom action that retrieves the log file and sends it to you.

Run part of a build script on a windows box and the rest on linux

My build script runs on linux and invokes things like gcc, shell scripts, etc.
Part of the solution is written in mono and could be compiled easily on linux.
But I want to obfuscate the code. Not manually, but as part of the build process.
Therefore I need to invoke Dotfuscator and Dotfuscator so far only runs on windows.
Is there a good solutions to invoke command line based workers/build scripts remotely from linux on a windows machine? I don't just want to run a command remotely, but also pass files along.
Like a windows service that is accessed using simple curl-uploads of a tar file, creates a temp folder for each concurrently connected client (or blocks concurrent calls) and unpacks the file, invokes something on these files and packages the result again as tar file to give it back to the caller? And clears the temp file even in case of failures?
Maybe someone knows a good solution that saves me from writing this myself!
It should not be so uncommon that a build process spans multiple platforms, yet common build server answers I found mainly talk about only one build script.
Also think about running e.g. the nsis setup builder from a linux driven build script, if part of your solution has a tiny windows component

How do we include a batch file in a msi installer which should run every time the msi is installed?

Wow do we include a batch file in a msi installer which should run every time the msi is installed?
I'm not sure but it might work if you create a custom action to execute cmd.exe and have the path and name of the batch file as a parameter.
Otherwise you can create a custom action that contains a vbscript file that executes the .bat file (or possibly you can use a vbscript instead of a bat file).
Just be aware that I've heard that some antivirus programs can get a bit nervous if you include scripts in your msi and might make the install fail.