{"record":{"id":"b6382897dc582243","repo":"different-ai/openwork","slug":"windows-rejected-the-organization-shortcut-shor","errorCode":null,"errorMessage":"Windows rejected the organization shortcut: ${shortcutPath}","messagePattern":"Windows rejected the organization shortcut: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"apps/desktop/electron/main.mjs","lineNumber":512,"sourceCode":"}\n\nasync function registerWindowsBrandShortcut(appId, appIconPath) {\n  if (process.platform !== \"win32\") return null;\n  const shortcutPath = windowsBrandShortcutPath();\n  const shortcutTempPath = `${shortcutPath}.${process.pid}.tmp.lnk`;\n  await mkdir(path.dirname(shortcutPath), { recursive: true });\n  // Recreate instead of replacing in place. Explorer can retain the old\n  // target and search metadata when a prior installer owned this path.\n  await rm(shortcutPath, { force: true });\n  await rm(shortcutTempPath, { force: true });\n  const details = windowsBrandShortcutDetails({\n    target: windowsExecutablePath(),\n    appId,\n    appIconPath,\n    appName: currentDisplayAppName,\n  });\n  const written = writeWindowsBrandShortcut(shell, shortcutTempPath, details, false);\n  if (!written) throw new Error(`Windows rejected the organization shortcut: ${shortcutPath}`);\n  await rename(shortcutTempPath, shortcutPath);\n  if (shell.readShortcutLink(shortcutPath).target !== details.target) {\n    repairWindowsShortcutTarget(shortcutPath, details);\n  }\n  const previousShortcutPath = await readWindowsBrandShortcutMarker();\n  if (previousShortcutPath && previousShortcutPath !== shortcutPath) {\n    await rm(previousShortcutPath, { force: true });\n  }\n  if (windowsInstalledShortcutPath() !== shortcutPath) {\n    await rm(windowsInstalledShortcutPath(), { force: true });\n  }\n  await writeFile(windowsBrandShortcutMarkerPath(), shortcutPath, \"utf8\");\n  return shortcutPath;\n}\n\nasync function removeWindowsBrandShortcut() {\n  if (process.platform !== \"win32\") return;\n  const shortcutPath = await readWindowsBrandShortcutMarker();","sourceCodeStart":494,"sourceCodeEnd":530,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/apps/desktop/electron/main.mjs#L494-L530","documentation":"registerWindowsBrandShortcut() creates the organization-branded .lnk shortcut via writeWindowsBrandShortcut(), which wraps Electron's shell.writeShortcutLink. If the COM/IShellLink operation fails (returns falsy), the code throws this error naming the intended final shortcut path. The shortcut is first written to a temp path, then renamed into place.","triggerScenarios":"Calling registerWindowsBrandShortcut() when writeWindowsBrandShortcut() returns false — Windows COM refuses to write the .lnk (invalid target/icon path, path on non-writable volume, shell COM initialization failure, or policy blocking shortcut creation).","commonSituations":"Enterprise GPO restrictions on .lnk creation; target executable path missing or containing characters IShellLink rejects; writing to ProgramData or a network drive without write permission; app running with insufficient privileges.","solutions":["Verify windowsExecutablePath() points to an existing .exe before creating the shortcut.","Ensure the destination directory (shortcutPath's folder) exists and the process has write permission.","Check Group Policy / antivirus rules that block .lnk file creation and whitelist the app.","Log the shell.writeShortcutLink failure detail inside writeWindowsBrandShortcut to surface the real COM error."],"exampleFix":"// before\nif (!written) throw new Error(`Windows rejected the organization shortcut: ${shortcutPath}`);\n// after\nif (!written) {\n  if (!fs.existsSync(details.target)) throw new Error(`Shortcut target missing: ${details.target}`);\n  throw new Error(`Windows rejected the organization shortcut: ${shortcutPath}`);\n}","handlingStrategy":"try-catch","validationCode":"import { existsSync, accessSync, constants } from 'node:fs';\nif (!existsSync(windowsExecutablePath())) throw new Error('shortcut target missing');\naccessSync(path.dirname(shortcutPath), constants.W_OK);","typeGuard":null,"tryCatchPattern":"try {\n  await registerWindowsBrandShortcut();\n} catch (err) {\n  if (String(err.message).startsWith('Windows rejected the organization shortcut')) {\n    console.error('Shortcut creation blocked — check target path, write perms, and GPO policy.', err.message);\n  } else throw err;\n}","preventionTips":["Confirm the target .exe exists before writing the .lnk.","Ensure the destination folder exists and is writable by the process.","Whitelist the app in enterprise policy/AV that blocks .lnk creation.","Log the shell.writeShortcutLink return value/failure reason for diagnostics."],"tags":["windows","shortcut","filesystem"],"backgroundTag":"shortcut-creation-failed","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}