Hi,
I answered my own question by developing the following Script that fully automates the cycling of the file sharing switch. It was quite tricky to get there, but had fun.
If its of any use to the community... And if anyone has suggestions to improve it...
Cheers,
-------------------------------------------------------------------------------
#This script cycles the file sharing switch OFF and ON, to force the "NetBIOS name" and the "Workgroup name" to re-appear in the Network "WINS" window. This is mandatory to allow SMB sharing from an external windows computer. OSX erases it at reboot for some reason … (bug?)
#Please adapt the words in quotes of this section according to the language of your computer (as you will notice, mine speaks French)
set Sharing_pane to "Partage"
set File_sharing_Off to "Partage de fichiers : désactivé"
set File_sharing_On to "Partage de fichiers : activé"
#Change "…" hereafeter with your own "password"
set Pass_word to "..."
tell application "System Preferences"
revealanchor "Main" of paneSharing_pane
run
end tell
tell application "System Events" to tell window Sharing_pane of application process "System Preferences"
# Unlock modifications
clickbutton 4
tell application "System Events" to tell window 1 of process "SecurityAgent"
set value of text field 2 of scroll area 1 of group 1 to Pass_word
delay 1
clickbutton 2 of group 2
delay 1
end tell
# If file sharing is ON than click it OFF
if (get value of checkbox 1 of row 2 of table 1 of scroll area 1 of group 1) = 1 then
clickcheckbox 1 of row 2 of table 1 of scroll area 1 of group 1
delay 1
# Next section waits for actual confirmation
repeat 15 times
if (name of static text 1 of group 1) is File_sharing_Off then
exit repeat
else
clickcheckbox 1 of row 2 of table 1 of scroll area 1 of group 1
delay 0.5
tell current application to beep 1
#Beep to indicate we had to click twice
end if
end repeat
end if
# If file sharing is OFF click it ON in any cases
if (get value of checkbox 1 of row 2 of table 1 of scroll area 1 of group 1) = 0 then
clickcheckbox 1 of row 2 of table 1 of scroll area 1 of group 1
# Next section waits for actual confirmation
repeat 15 times
if (name of static text 1 of group 1) is File_sharing_On then
exit repeat
else
clickcheckbox 1 of row 2 of table 1 of scroll area 1 of group 1
delay 0.5
tell current application to beep 2
end if
end repeat
end if
# Lock modifications
clickbutton 4
delay 0.5
#Back to main window
clickbutton 1 of group 1 of group 2 of tool bar 1
end tell
tell application "System Preferences" to quit
# Beep four times to tell its done
tell current application to beep 4
-------------------------------------------------------------------------------- -----