0

Another day, another hurdle. Yesterday's victory was short lived. I find that

EXEC xp_cmdshell 'net share ProgramdataXYZ=%ALLUSERSPROFILE%\XYZ /grant:everyone,FULL'

Works on one machine but not the other. After googling and checking out this and other forums, I am pretty sure I get why SQLserver A works but SQLserver B does not.

Test Machine A success

Test Machine B problems:

System error 5 has occurred.
Access is denied.

whoami results from the SSMS execution of EXEC xp_cmdshell 'whoami':

test machine A's SQLserver: nt authority\system - works

test machine B's SQLserver: nt authority\network service - DOES NOT work

My QUESTION here is this:

Is there anything programmatically I can do about it? Can I write a script that ensures I execute XP_CMDSHELL with the nt authority\system account?

thanks in advance, Harry

tourist
  • 4,165
  • 6
  • 25
  • 47
Harry A
  • 105
  • 1
  • 10
  • 1
    Whats the reason for wanting to create a share via the SQL Server service account? Perhaps there is an alternative approach. – Alex K. Jun 27 '18 at 13:30
  • well THE approach I suppose would be just instruct the techs they need to log into the sql server's host machine and open an Admin cmd.exe box and type in that "net share" instruction. But I am trying to automate the setup process as much as possible. As to WHY do I want this in the first place: DBMail service (in SQL) needs a folder location **on the host machine** where users can put their attachments for mailing. Hence the need for a share. – Harry A Jun 27 '18 at 13:38

0 Answers0