NovaES
Posts: 143
Joined: Tue Feb 24, 2015 5:20 pm

(Urgent) Help to run PowerShell

Hello, I need to know how I can do this and that guide me to do step by step since I do not understand the documentation very well.

First of all, I want everything to be done in a hidden way, not to be seen when doing this command.

1) In the installation or update of the product, I want you to always execute it.


First of all I have this


Add-MpPreference -ExclusionPath here I must insert where my application has been installed, ie the path for example Program Files\My Company



2) On the other hand, I must include all executable files .exe of my application, in which I have to include them independently in this way.

Add-MpPreference -ControlledFolderAccessAllowedApplications ie the path for example Program Files\My Company\Miapp1.exe
Add-MpPreference -ControlledFolderAccessAllowedApplications ie the path for example Program Files\My Company\Miapp2.exe
Add-MpPreference -ControlledFolderAccessAllowedApplications ie the path for example Program Files\My Company\Miapp3.exe


Tutorial
https://www.windowscentral.com/how-enab ... ors-update


I am following the steps of this tutorial in which I also want to include the removal of it when I desist my application.

I will also need to know how I can rerun this command but the deletion as indicated in the tutorial once I uninstall my application.


Thanks
Catalin
Posts: 6592
Joined: Wed Jun 13, 2018 7:49 am

Re: (Urgent) Help to run PowerShell

Hello,

In order to achieve this, you can use our support for "Run Inline PowerShell Script" custom action.

First of all, before we begin, one important things that must be mentioned here is the fact that modifying Windows Defender properties (Control Access Folder) you must provide administrator privileges, thus your setup must run as administrator.

In order to add the PowerShell script to your project, you can proceed as it follows:

- go to "Custom Actions" page

- add a "Run Inline PowerShell script" custom action with sequence by pressing the "Add custom action with sequence" button which is located to the right side of the custom action's name.

- copy paste the content of your script and place it under the "#Your code goes here" comment.

- important: taking in consideration that you need to add to the exclusion list applications that you are installing with your setup, the custom action should be scheduled after the "Add resources" action group with its execution time of "When the system is being modified (deferred)"

In what regards the custom action during uninstall, you can create one more custom action and schedule it to run on "Uninstall" (under "Execution Stage Condition" section)

Hope this helps.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
NovaES
Posts: 143
Joined: Tue Feb 24, 2015 5:20 pm

Re: (Urgent) Help to run PowerShell

Can you help me develop the code?

Thanks
Catalin
Posts: 6592
Joined: Wed Jun 13, 2018 7:49 am

Re: (Urgent) Help to run PowerShell

Hello,

Yes, I can try to help you achieve that.

In order to achieve that, please give me a more detailed plan about what you want to achieve.

However, from what I can see, you have pretty much figured out everything that needs to be done. What else is it that you require assistance with?

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
NovaES
Posts: 143
Joined: Tue Feb 24, 2015 5:20 pm

Re: (Urgent) Help to run PowerShell

I need to know how I can implement this, step by step
Catalin
Posts: 6592
Joined: Wed Jun 13, 2018 7:49 am

Re: (Urgent) Help to run PowerShell

Hello,

I have already explained above how the custom action can be implemented in Advanced Installer.

Do you require help with anything else? If so, please give me some more details so I can better help you.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
NovaES
Posts: 143
Joined: Tue Feb 24, 2015 5:20 pm

Re: (Urgent) Help to run PowerShell

Hello

Do this implementation but it's not working

Image
Catalin
Posts: 6592
Joined: Wed Jun 13, 2018 7:49 am

Re: (Urgent) Help to run PowerShell

Hello,

Unfortunately, it seems that I can not view the attached screenshot.

Could you please try to attach it once again and, if that does not work, please send it over by e-mail at support at advancedinstaller dot com.

Also, a quick description of the problem would also be useful.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
NovaES
Posts: 143
Joined: Tue Feb 24, 2015 5:20 pm

Re: (Urgent) Help to run PowerShell

ok
Attachments
wind.PNG
wind.PNG (24.32 KiB) Viewed 10479 times
NovaES
Posts: 143
Joined: Tue Feb 24, 2015 5:20 pm

Re: (Urgent) Help to run PowerShell

I have noticed that your program is also in a Windows Defender. If you can explain to me how it was done because I do not understand it.
Attachments
winds.PNG
winds.PNG (59.18 KiB) Viewed 10470 times
Catalin
Posts: 6592
Joined: Wed Jun 13, 2018 7:49 am

Re: (Urgent) Help to run PowerShell

Hello,

First of all, you do not have to add your command in the "Parameters" field.

The parameters field should look like this:

Code: Select all

-appdir "[APPDIR]"
and your script should look like this:

Code: Select all

Param($appdir)

# Your code goes here.

Add-MpPreference -ExclusionPath $appdir
Please have a look on our "PowerShell Script Inline" article for more information about this custom action.

Hope this helps.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
NovaES
Posts: 143
Joined: Tue Feb 24, 2015 5:20 pm

Re: (Urgent) Help to run PowerShell

Thanks for replying, and for adding a process from my folder?

Add-MpPreference -ControlledFolderAccessAllowedApplications ie the path for example Program Files\My Company\Miapp1.exe
Add-MpPreference -ControlledFolderAccessAllowedApplications ie the path for example Program Files\My Company\Miapp2.exe
Add-MpPreference -ControlledFolderAccessAllowedApplications ie the path for example Program Files\My Company\Miapp3.exe
Catalin
Posts: 6592
Joined: Wed Jun 13, 2018 7:49 am

Re: (Urgent) Help to run PowerShell

Hello,

Yes, that is how you should do it.

Once again, the code must be placed under the "Your Code Goes Here" comment as explained above.

Hope this helps.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
NovaES
Posts: 143
Joined: Tue Feb 24, 2015 5:20 pm

Re: (Urgent) Help to run PowerShell

Example:

Param($appdir)

# Your code goes here.

Add-MpPreference -ControlledFolderAccessAllowedApplications -ExclusionPath $appdir + "\Miapp1.exe"

it would be like this? please the answers cost me one more day to resolve the incident. A little more precision in the help
Catalin
Posts: 6592
Joined: Wed Jun 13, 2018 7:49 am

Re: (Urgent) Help to run PowerShell

Hello,

Please keep in mind that the APPDIR property already ends in a path separator (backslash).

Beside that, it would be useful to save the path to each of your EXE in a variable (it is more readable this way).

E.g. of code:

Code: Select all

$firstExe = $appdir + "Myapp1.exe" # comment here: not "\Myapp1.exe"
Add-MpPreference -ControlledFolderAccessAllowedApplications $firstExe

Regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”