From 3dd03d7efc8d7996e45f4b7192231ee25cc21d89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Uwe=20J=C3=A4ger?= Date: Mon, 17 Mar 2014 15:11:45 +0100 Subject: [PATCH] Make shared folder type smb work for non-english windows the grant "Everyone,Full" does not work on localized versions of windows, in German it is "Jeder" in Spanish "Todos". Also the net share command returns localized texts, so the -Match does not work for non-english Windows. I could not test exactly that version, copied relevant bits from my modified lokal version. --- plugins/synced_folders/smb/scripts/set_share.ps1 | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/plugins/synced_folders/smb/scripts/set_share.ps1 b/plugins/synced_folders/smb/scripts/set_share.ps1 index ec9097672..ac49d1c83 100644 --- a/plugins/synced_folders/smb/scripts/set_share.ps1 +++ b/plugins/synced_folders/smb/scripts/set_share.ps1 @@ -19,7 +19,12 @@ if ($existing_share) { net share $share_name /delete /y } -$grant = "Everyone,Full" +# The names of the user are language dependent! +$objSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-1-0") +$objUser = $objSID.Translate([System.Security.Principal.NTAccount]) + +$grant = "$objUser,Full" + if (![string]::IsNullOrEmpty($host_share_username)) { $computer_name = $(Get-WmiObject Win32_Computersystem).name $grant = "$computer_name\$host_share_username,Full" @@ -38,7 +43,7 @@ if (![string]::IsNullOrEmpty($host_share_username)) { } $result = net share $share_name=$path /unlimited /GRANT:$grant -if ($result -Match "$share_name was shared successfully.") { +if ($LastExitCode -eq 0) { exit 0 }