{"record":{"id":"d512065138d757ad","repo":"hashicorp/vagrant","slug":"vagrant-requires-administrator-access-to-create-sm","errorCode":null,"errorMessage":"Vagrant requires administrator access to create SMB shares and\nmay request access to complete setup of configured shares.","messagePattern":"Vagrant requires administrator access to create SMB shares and\nmay request access to complete setup of configured shares\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"plugins/hosts/windows/cap/smb.rb","lineNumber":109,"sourceCode":"                  name: data[:smb_id]\n              end\n              @@logger.info(\"skip creation of existing share name=#{name} id=#{data[:smb_id]}\")\n              next\n            end\n\n            @@logger.info(\"creating new share name=#{name} id=#{data[:smb_id]}\")\n\n            shares << [\n              \"\\\"#{hostpath.gsub(\"/\", \"\\\\\")}\\\"\",\n              name,\n              data[:smb_id]\n            ]\n          end\n          if !shares.empty?\n            uac_notified = false\n            shares.each_slice(10) do |s_shares|\n              if !uac_notified\n                machine.env.ui.warn(\"\\n\" + I18n.t(\"vagrant_sf_smb.uac.create_warning\") + \"\\n\")\n                uac_notified = true\n                sleep(UAC_PROMPT_WAIT)\n              end\n              result = Vagrant::Util::PowerShell.execute(script_path, *s_shares, sudo: true)\n              if result.exit_code != 0\n                share_path = result.stdout.to_s.sub(\"share path: \", \"\")\n                raise SyncedFolderSMB::Errors::DefineShareFailed,\n                  host: share_path,\n                  stderr: result.stderr,\n                  stdout: result.stdout\n              end\n            end\n          end\n        end\n\n        # Generate a list of existing local smb shares\n        #\n        # @return [Hash]","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/hashicorp/vagrant/blob/35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5/plugins/hosts/windows/cap/smb.rb#L91-L127","documentation":"On Windows hosts, creating SMB shares for synced folders runs an elevated PowerShell script in batches of 10 shares. Before the first batch, Vagrant prints this UAC warning once, sleeps UAC_PROMPT_WAIT seconds, and executes the script with sudo: true; a non-zero exit raises SyncedFolderSMB::Errors::DefineShareFailed with the failing share path.","triggerScenarios":"`vagrant up` or `vagrant reload` with type: \"smb\" synced folders on a Windows host where the shares list is non-empty (new or changed host paths to expose).","commonSituations":"First SMB up on a Windows host; adding new shared folders mid-project; non-elevated terminals triggering UAC prompts; CI agents without interactive elevation.","solutions":["Run Vagrant from an elevated (Administrator) terminal so share creation does not need an interactive UAC dialog","Pre-create the shares yourself with New-SmbShare if you must avoid elevation during up","If DefineShareFailed follows, check the share path, firewall rules, and File and Printer Sharing are enabled"],"exampleFix":"# before\nvagrant up   # normal terminal -> UAC consent dialog mid-run\n# after\n# elevated PowerShell:\nvagrant up","handlingStrategy":"validation","validationCode":"# PowerShell preflight: is this shell elevated?\n([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Start elevated shells before `vagrant up` with type: smb folders","Verify File and Printer Sharing and firewall rules before first up","Watch for SyncedFolderSMB::Errors::DefineShareFailed right after this warning; it names the failing share path"],"tags":["vagrant","smb","windows-host","uac","share-creation"],"backgroundTag":"privilege-elevation-required","analyzedSha":"35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5","analyzedAt":"2026-08-21T13:34:32.514Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}