GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Handle case where applocker test script fails to delete by SteveL-MSFT · Pull Request #8627 · PowerShell/PowerShell

Conversation

@SteveL-MSFT

@SteveL-MSFT Steve Lee (SteveL-MSFT) commented Jan 11, 2019 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

PR Summary

One reported case where during applocker policy check, the test script that is created cannot be deleted because something else (malware scanner?) has a lock on the file. This results in an exception being thrown in finally block which ultimately causes PowerShell to crash due to the unhandled exception. Fix is to wrap the deletion in the finally block with try..catch and ignore any exceptions and leave the temp file.

TFS:20156282

PR Checklist

  • PR has a meaningful title
    • Use the present tense and imperative mood when describing your changes
  • Summarized changes
  • Change is not breaking
  • Make sure all .h, .cpp, .cs, .ps1 and .psm1 files have the correct copyright header
  • This PR is ready to merge and is not Work in Progress.
    • If the PR is work in progress, please add the prefix WIP: to the beginning of the title and remove the prefix when the PR is ready.
  • User-facing changes
    • Not Applicable
    • OR
    • User-facing Documentation needed
      • Issue filed - Issue link:
  • Testing - New and feature
    • Not Applicable or can only be tested interactively
    • OR
    • Make sure you've added a new test if existing tests do not effectively test the code changed
      • Add [feature] if the change is significant or affects feature tests

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@SteveL-MSFT
handle case where applocker test script fails to delete
216d24f
@SteveL-MSFT Steve Lee (SteveL-MSFT) assigned Travis Plunk (TravisEz13) Jan 11, 2019
@SteveL-MSFT
Steve Lee (SteveL-MSFT) requested a review from Paul Higinbotham (PaulHigin) January 11, 2019 18:32
PaulHigin
Paul Higinbotham (PaulHigin) approved these changes Jan 11, 2019
View reviewed changes
anmenaga
Andrew (anmenaga) reviewed Jan 11, 2019
View reviewed changes
Comment thread src/System.Management.Automation/security/wldpNativeMethods.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

@iSazonov Ilya (iSazonov) added the CL-Engine Indicates that a PR should be marked as an engine change in the Change Log label Jan 12, 2019
@iSazonov

Ilya (iSazonov) commented Jan 12, 2019 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator

If we can not delete the file is it secure to leave it on file system?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@SteveL-MSFT
address Andrew and Ilya's feedback
081e432
@SteveL-MSFT

Steve Lee (SteveL-MSFT) commented Jan 15, 2019

Copy link
Copy Markdown
Member Author

Ilya (@iSazonov) yes, the test script is harmless and doesn't expose anything, it just validates whether scripts can be run or not. It is not ideal to leave the file in the temp folder, but worse is to prevent PowerShell from starting simply because something else decided to lock that file.

iSazonov reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@SteveL-MSFT

Steve Lee (SteveL-MSFT) commented Jan 15, 2019

Copy link
Copy Markdown
Member Author

Paul Higinbotham (@PaulHigin) can you take another look? Made some changes based on feedback

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

iSazonov
Ilya (iSazonov) approved these changes Jan 15, 2019
View reviewed changes
PaulHigin
Paul Higinbotham (PaulHigin) approved these changes Jan 15, 2019
View reviewed changes
@iSazonov

Ilya (iSazonov) commented Jan 16, 2019

Copy link
Copy Markdown
Collaborator

Travis Plunk (@TravisEz13) Please merge the PR.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@TravisEz13
Travis Plunk (TravisEz13) merged commit a04f694 into PowerShell:master Jan 16, 2019
@SteveL-MSFT
Steve Lee (SteveL-MSFT) deleted the applocker-policy branch January 18, 2019 04:34
@Niehweune John De Clerck (Niehweune) mentioned this pull request Jun 4, 2021
PowerShell fails to start in case of weird permissions in TEMP/strange behavior of antivirus #15523
Closed
Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj-contribs/PowerShell that referenced this pull request Aug 6, 2026
@SteveL-MSFT @TravisEz13
Handle case where applocker test script fails to delete (PowerShell#8627
1815488
)

One reported case where during applocker policy check, the test script that is created cannot be deleted because something else (malware scanner?) has a lock on the file.  This results in an exception being thrown in finally block which ultimately causes PowerShell to crash due to the unhandled exception.  Fix is to wrap the deletion in the finally block with try..catch and ignore any exceptions and leave the temp file.

TFS:20156282
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@iSazonov Ilya (iSazonov) iSazonov approved these changes
+2 more reviewers
@anmenaga Andrew (anmenaga) anmenaga left review comments
@PaulHigin Paul Higinbotham (PaulHigin) PaulHigin approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@TravisEz13 Travis Plunk (TravisEz13)

Labels

CL-Engine Indicates that a PR should be marked as an engine change in the Change Log

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@SteveL-MSFT @iSazonov @anmenaga @PaulHigin @TravisEz13
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.