{"record":{"id":"a45a6d2ccfecd330","repo":"hashicorp/terraform","slug":"using-the-c-windows-temp-folder-is-not-supported","errorCode":null,"errorMessage":"Using the C:\\Windows\\Temp folder is not supported. Please use a different 'script_path'.","messagePattern":"Using the C:\\\\Windows\\\\Temp folder is not supported\\. Please use a different 'script_path'\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/communicator/winrm/provisioner.go","lineNumber":114,"sourceCode":"// a ConnectionInfo struct\nfunc parseConnectionInfo(v cty.Value) (*connectionInfo, error) {\n\tv, err := shared.ConnectionBlockSupersetSchema.CoerceValue(v)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tconnInfo, err := decodeConnInfo(v)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\t// Check on script paths which point to the default Windows TEMP folder because files\n\t// which are put in there very early in the boot process could get cleaned/deleted\n\t// before you had the change to execute them.\n\t//\n\t// TODO (SvH) Needs some more debugging to fully understand the exact sequence of events\n\t// causing this...\n\tif strings.HasPrefix(filepath.ToSlash(connInfo.ScriptPath), \"C:/Windows/Temp\") {\n\t\treturn nil, fmt.Errorf(\n\t\t\t`Using the C:\\Windows\\Temp folder is not supported. Please use a different 'script_path'.`)\n\t}\n\n\tif connInfo.User == \"\" {\n\t\tconnInfo.User = DefaultUser\n\t}\n\n\t// Format the host if needed.\n\t// Needed for IPv6 support.\n\tconnInfo.Host = shared.IpFormat(connInfo.Host)\n\n\tif connInfo.Port == 0 {\n\t\tif connInfo.HTTPS {\n\t\t\tconnInfo.Port = DefaultHTTPSPort\n\t\t} else {\n\t\t\tconnInfo.Port = DefaultPort\n\t\t}\n\t}","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/communicator/winrm/provisioner.go#L96-L132","documentation":"Raised by the WinRM communicator's parseConnectionInfo when the connection block's script_path normalizes under C:\\Windows\\Temp. Terraform copies the remote-exec script to script_path on the Windows target before executing it; files placed in the system temp folder are cleaned early during boot and can be deleted before the script runs, causing flaky provisioning. The check (line 113) is a hard block, not a warning.","triggerScenarios":"A `connection { type=\"winrm\" script_path = \"C:\\\\Windows\\\\Temp\\\\...\" }` (any casing or separator style that ToSlash-normalizes to the `C:/Windows/Temp` prefix). Also when reusing a script_path default across OS targets without adapting it for WinRM.","commonSituations":"Sharing one script_path variable between ssh and winrm blocks, defaulting to the system temp folder out of habit, CI images whose TMP points at C:\\Windows\\Temp and the operator hardcodes that path.","solutions":["Point script_path at a stable folder that survives boot, e.g. C:\\Temp or the user profile: `script_path = \"C:\\\\Temp\\\\terraform_%RAND%.cmd\"` (the WinRM DefaultScriptPath).","Omit script_path entirely and let Terraform use DefaultScriptPath (C:/Temp/terraform_%RAND%.cmd).","Ensure the target folder exists and the WinRM user has write+execute permissions on it."],"exampleFix":"// before\nconnection {\n  type        = \"winrm\"\n  script_path = \"C:\\\\Windows\\\\Temp\\\\tf.cmd\"\n}\n\n// after\nconnection {\n  type        = \"winrm\"\n  script_path = \"C:\\\\Temp\\\\terraform_%RAND%.cmd\"\n}","handlingStrategy":"validation","validationCode":"// Reject the blocked Windows temp path before applying a winrm connection block.\npath := filepath.ToSlash(strings.ToLower(connInfo.ScriptPath))\nif strings.HasPrefix(path, \"c:/windows/temp\") {\n    return errors.New(\"script_path must not be under C:\\\\Windows\\\\Temp; use C:\\\\Temp\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always use a dedicated C:\\Temp (or %USERPROFILE%) folder for WinRM scripts.","Don't share one script_path variable between ssh and winrm connection blocks.","Omit script_path to accept the safe WinRM default (C:/Temp/terraform_%RAND%.cmd)."],"tags":["winrm","provisioner","windows","connection-block"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T20:17:04.800Z"}