1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

「アプリケーション制御ポリシーによってこのファイルがブロックされました」というエラーを、スマートアプリコントロールをオフにして解決した

1
Posted at

環境

  • Windows 11 Pro 25H2
  • OSビルド: 26200.8117
  • uv v0.9.17 (2b5d65e61 2025-12-09)
  • Python 3.12.8

やりたいこと

%LOCALAPPDATA%にあるexeファイルを、Pythonのsubprocess.runで呼び出したいです。
具体的にはnextcloud-cliのexeファイルです。
exeファイルのパスは%LOCALAPPDATA%\nextcloud-cli\nextcloud-cli.exeです。

Pythonスクリプトを実行したら、「アプリケーション制御ポリシーによってこのファイルがブロックされました。」というエラーが発生しました。

  File "C:\Users\yuji\Documents\foo\nextcloud_client.py", line 186, in list_remote_files
    result = subprocess.run(
             ^^^^^^^^^^^^^^^
  File "C:\Users\yuji\AppData\Roaming\uv\python\cpython-3.12.8-windows-x86_64-none\Lib\subprocess.py", line 548, in run
    with Popen(*popenargs, **kwargs) as process:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\yuji\AppData\Roaming\uv\python\cpython-3.12.8-windows-x86_64-none\Lib\subprocess.py", line 1026, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Users\yuji\AppData\Roaming\uv\python\cpython-3.12.8-windows-x86_64-none\Lib\subprocess.py", line 1538, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: [WinError 4551] アプリケーション制御ポリシーによってこのファイルがブロックされました。

解決策

Windowsセキュリティで「スマートアプリコントロール」の設定を確認したところ、オンになっていました。
https://learn.microsoft.com/ja-jp/windows/apps/develop/smart-app-control/overview

スマートアプリコントロールをオフにしたら、nextcloud-cli.exeを実行できました。

image.png

補足

試したけど解決できなかった方法

%LOCALAPPDATA%\nextcloud-cliフォルダを、Microsoft Defenderのウイルス対策のスキャンから除外するよう設定してみました。
しかし、スマートアプリコントロールがオンの状態では、nextcloud-cli.exeの実行はブロックされました。

image.png

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?