Kaspersky repeatedly deletes Agent temp PowerShell (ps-script-*.ps1) — options when exclusions are not allowed

Prerequisite
In our environment we cannot add Kaspersky Endpoint Security exclusions (scan exclusions, trusted applications, etc.). This post assumes that constraint.

Environment
- OS: Windows [10/11] [64-bit]
- Cursor: [paste from Menu → About → Copy]
- Usage: Agent mode running terminal/shell commands
- Endpoint AV: Kaspersky Endpoint Security [12.10], managed by Kaspersky Security Center

Issue
Whenever the Agent runs a command, Kaspersky detects and deletes a temporary PowerShell script:

- Path: C:\Users\[user]\AppData\Local\Temp\
- File name: ps-script-[GUID].ps1
- Detection: HEUR:Trojan.PowerShell.Agent.gen
- Result: Deleted (multiple times, e.g. 2026-10-22 and 2026-10-27)

I do not see the same detections while Cursor is closed; they appear tied to Agent shell execution.

What I checked
- When inspected before deletion, the script looked like an Agent wrapper (Base64 env setup, working directory, user command, Dump-PowerShellState, etc.).
- Similar ps-script-*.ps1 + Cursor Agent reports exist on the Kaspersky forum as likely false positives.
- I understand that on Windows the Agent may still generate temp PowerShell scripts even when terminal.integrated.automationProfile.windows is set to cmd.exe.

Questions
1. Without AV exclusions on the endpoint, is there any supported way to keep Agent shell execution working (settings, execution path, alternative modes)?
2. Any product-side plan to avoid writing temp ps-script-*.ps1 under Temp (e.g. direct cmd execution)?
3. If we report a false positive to Kaspersky, does Cursor recommend specific information to include (repro steps, versions, log types)?

Thank you.

Where does the bug appear (feature/product)?

Cursor CLI

Describe the Bug

Summary

Kaspersky rule “Launch Windows PowerShell from JScript” blocks Agent CLI when it runs
PowerShell via a temp script:
powershell.exe -ExecutionPolicy Bypass -NonInteractive -File
%LOCALAPPDATA%\Temp\ps-script-.ps1
Attributed source: cursor-agent …\index.js

Impact

Any Shell tool usage that goes through PowerShell on Windows causes AAC alerts.
Users without Kaspersky admin rights cannot allowlist.

Request

  • Prefer cmd.exe for simple Windows shell when possible
  • Or run PowerShell without the JScript→powershell parent chain that triggers AAC
  • Document enterprise exclusions for Agent CLI

Environment

  • Same as above; seen alongside the reg.exe blocks

Steps to Reproduce

Environment: Windows 10 with Kaspersky Adaptive Anomaly Control enabled; Cursor Agent CLI installed (e.g. 2026.10.22-27dcf5f, under a path such as C:\siemens\cursor-agent\ or the default install location).

  1. (Optional) In the agent chat, ask it to run a PowerShell command via Shell, e.g. “run in PowerShell: Get-Date”.
  2. Observe a second alert with a rule similar to “Launch of Windows PowerShell from a JScript script”:
    • Source process: the same index.js
    • Target: powershell.exe -ExecutionPolicy Bypass -NonInteractive -File …\Temp\ps-script-.ps1

Expected: Agent starts and works without EDR blocks, and without needing to spawn System32\reg.exe or temp .ps1 files from Node/index.js.

Actual: Kaspersky blocks the actions and shows alerts; when reg.exe is blocked, the agent reports that it cannot read/update the user PATH via the registry.

Operating System

Windows 10/11

Version Information

Cursor CLI

Does this stop you from using Cursor

No - Cursor works, but with this issue

Hi @Hayato_Moritan,

Right, on Windows the Agent’s default shell runner writes a ps-script-.ps1 wrapper to %TEMP% for each command, and automationProfile doesn’t change that. Two settings avoid the file:

  1. Cursor Settings → Agents → Terminal and Editing → turn on Legacy Terminal Tool. Commands then run directly as powershell.exe -c "<command>" with no script file. The trade-off is that the working directory and environment variables don’t carry over between commands.
  2. If Git for Windows is installed, set "terminal.integrated.defaultProfile.windows": "Git Bash" in your settings.json and restart Cursor. The Agent then runs commands in Git Bash, which doesn’t use the .ps1 wrapper.

After switching, have the Agent run something simple and check whether Kaspersky still reports anything.

For the Kaspersky report, include the detection name, your KES version and database date, the file path pattern, that Cursor starts it as powershell.exe -ExecutionPolicy Bypass -File <script>, your Cursor version (Help → About), and that any Agent terminal command reproduces it. Don’t send a captured script as is: it contains your environment variables Base64-encoded, which can include tokens.

Thanks — Legacy Terminal Tool / Git Bash as terminal.integrated.defaultProfile.windows makes sense for the Cursor IDE Agent.

We mainly use the standalone Agent CLI on Windows (agent / cursor-agent, installed under a path like
C:\Users\User\cursor-agent\versions\…\index.js).

For the CLI we still see Kaspersky Adaptive Anomaly Control block:

powershell.exe -ExecutionPolicy Bypass -NonInteractive -File %TEMP%\ps-script-.ps1

with source attributed to …\cursor-agent\versions\index.js.

Questions:

  1. Do Legacy Terminal Tool or IDE terminal.integrated.* settings affect the Windows Agent CLI Shell tool at all?
  2. If not, is there a CLI-side setting/env flag (e.g. in cli-config.json) to avoid the %TEMP%\ps-script-*.ps1 wrapper — equivalent to Legacy
    Terminal (powershell.exe -c …) or to force cmd.exe / bash without writing a temp .ps1?
  3. If none exists today, what’s the recommended enterprise workaround for CLI-only users (besides WSL or a Kaspersky allowlist)?

Happy to provide Cursor CLI version, KES rule name, and a redacted cmdline. We will not attach the temp .ps1 (env may contain secrets).

Following up after checking https://cursor.com/docs/cli:

We don’t see any CLI setting that maps to IDE Legacy Terminal Tool or that disables the Windows %TEMP%\ps-script-*.ps1 PowerShell wrapper.
Shell Mode docs refer to $SHELL / bash/zsh; the CLI changelog states Windows agent shell commands run in PowerShell.

Can you confirm there’s currently no cli-config.json / env / flag to:
• run CLI Shell as powershell.exe -c … without a temp .ps1, or
• force cmd.exe / Git Bash for the Windows Agent CLI Shell tool?

If none exists, is WSL Agent CLI the recommended path for enterprise EDR that blocks “PowerShell launched from JScript/Node”?

Hi @xpresstoparadise,

To answer your questions:

  1. No. Legacy Terminal Tool and the terminal.integrated.* settings only apply to the desktop app. The CLI doesn’t read them.
  2. There’s no CLI setting or environment variable for this today. On Windows the CLI runs each Shell command through the ps-script-*.ps1 wrapper, which is how it keeps the working directory and environment between commands. There’s an open request for a shell option in the CLI, but no timeline.
  3. This is how the CLI works on Windows, so for managed machines an allowlist is what we recommend. Your Kaspersky admin would need to allow PowerShell being started by the CLI’s index.js (under your cursor-agent\versions\ folder) for the “Launch Windows PowerShell from JScript” rule, and scripts matching %LOCALAPPDATA%\Temp\ps-script-*.ps1.

If an allowlist isn’t possible and Git for Windows is installed, you can try starting the CLI from a Git Bash window instead (run agent, or agent.cmd if Git Bash can’t find it). The CLI then runs commands through Git Bash and doesn’t write the .ps1 file. It will still start PowerShell if you explicitly ask it to run a PowerShell command. We haven’t tested this against Kaspersky’s rules, so let me know whether the alerts stop.

Thanks — that matches what we see in the CLI docs (no Legacy Terminal equivalent for CLI; Windows Shell uses the ps-script-*.ps1 wrapper).

Update after trying your Git Bash suggestion:

• Starting via agent.cmd from Git Bash was unreliable for us: agent.cmd still launches powershell.exe to run cursor-agent.ps1, so startup often hung / was
blocked under Kaspersky AAC.
• Starting the CLI directly with the versioned node.exe + index.js from a Git Bash environment (so SHELL is bash) works. After that, simple Shell commands no
longer trigger the Kaspersky alert for %TEMP%\ps-script-*.ps1.

We’ll keep WSL and/or a Kaspersky allowlist as the durable options for managed machines, and treat Git Bash + direct node as a workable workaround when allowlist
isn’t available yet.

We’re also waiting for an update on our ticket / the open request for a first-class CLI shell option (cmd / bash / “no temp ps1” on Windows). Please keep us
posted when there’s any progress or a timeline — that would help enterprise Windows users a lot.

Thanks again.

@Colin Thank you for the detailed answer — that helps a lot.

I understand the goal is to avoid the %TEMP%\ps-script-*.ps1 wrapper path, not to ban PowerShell entirely (Legacy Terminal still uses powershell.exe -c, and Git Bash is mainly for routing Shell away from that wrapper).

I have not changed those settings yet. At the moment I cannot reproduce the Kaspersky detection on my side, but I will try Legacy Terminal Tool first, then Git Bash as the default profile, if HEUR:Trojan.PowerShell.Agent.gen shows up again when the Agent runs Shell commands.

I will also pass your Kaspersky reporting checklist to our admin (without attaching captured .ps1 files).

Thanks again.

Same setup here: Kaspersky Endpoint Security on a managed Windows PC, no rights to add exclusions. Two things that bit me besides the ps-script detections, in case they save someone time:

  1. Kaspersky’s HTTPS inspection re-signs TLS with its own root. Node-based tools (agent CLIs, MCP servers started with npx) don’t use the Windows certificate store by default, so they fail with network errors while the browser works fine. Running Node with --use-system-ca fixed it for me, no NODE_EXTRA_CA_CERTS needed.

  2. It also blocked an executable unpacked under %LOCALAPPDATA%\npm-cache\_npx (EPERM). The request I took to IT was a folder exclusion for that path, which is a much smaller ask than allowlisting PowerShell.

I observed a similar pattern on Windows 10 with the Cursor desktop app and Kaspersky Premium.

On November 6, 2026, Kaspersky recorded four detections at 07:18, 07:31, 10:02, and 10:31 local time. Each entry had a different ps-script-*.ps1 filename under %LOCALAPPDATA%\Temp. The detailed report for the first event listed powershell.exe, identified the detection as PDM:Trojan.Win32.Generic, and recorded both “process terminated” and “could not delete.” Kaspersky’s Quarantine view later showed all four script entries as “Not active.”

The alerts coincided with my work in Cursor Agent across two local repositories. I did not notice similar alerts before or after those sessions. I have not captured the parent process, the full command line, or the script contents, so I cannot confirm what launched the scripts or whether the detections were false positives.

A subsequent Kaspersky full scan reported no active threats. The deletion entries in the scan report were associated with an old Hiren’s BootCD ISO in a backup. The PowerShell scripts did not appear in that scan report.

Could the Cursor team confirm whether the desktop Agent on Windows creates temporary ps-script-<GUID>.ps1 files when it runs terminal commands? Which Cursor log or diagnostic would help me match a filename and timestamp to the exact Agent command? If this is a known compatibility issue, is there a supported workaround that keeps Kaspersky enabled without excluding the Temp folder?

Thanks!

Hi @SmartAdPanel, yes. On Windows the desktop Agent writes a ps-script-<GUID>.ps1 file to %LOCALAPPDATA%\Temp for each terminal command it runs, and removes it once the command finishes, so detections lining up with your Agent sessions fits.

Cursor doesn’t log those filenames, so there’s no log that maps a GUID to a specific command. The practical match is by time: the Agent chat shows each terminal command it ran, and one Kaspersky terminated will have failed or come back empty around the detection time. Kaspersky’s detailed event should also show powershell.exe started by Cursor with -ExecutionPolicy Bypass -NonInteractive -File pointing at that script.

To avoid the file without excluding Temp, the two options in this earlier reply apply to you too: turn on Legacy Terminal Tool under Cursor Settings → Agents → Terminal and Editing, or make Git Bash your default terminal profile if Git for Windows is installed. If the alerts stop after switching, that confirms the wrapper is what Kaspersky was flagging.