Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

xp_cmdshell vs psexec - this SQL server forgets credential to an W10 share

Volvere

IS-IT--Management
Sep 13, 2024
1
0
1
Hello all

Facts:
1. We have an Windows 2008 R2 server with MS SQL server 2012 on it, which hosts an small ERP, which exports some XMLs on a W10 share (this export fails after reboot).
2. the the ERP exports any XMLs on the W10 share without problems upon instalation/initial config (but not after reboot).
3. me - no SQL Server able (also not authorized, it's the ERP's vendor playground, who says that the problem is the server).
4. Any other user remembers network shares forever, absolutely no incident with any of them, ever (reboot, power outage, no matter what).


Problem: upon reboot, the Windows server 2008R2/ERP/SQL server (which runs on Service_Account: NT SERVICE\MSSQLSERVER) forgets the credentials to this W10 share, so the XML export does not work anymore. (the guru's script shows that the name+pass are no more there).


ERP's SQL guru shows me a script in Microsoft SQL Server Management studio which saves / tests these credentials successfully. Basically, using xp_cmdshell 'cmdkey /add ...' he adds the user and then shows me that the share is accessible, and the ERP can export its XMLs there.



My part (trying to emulate guru's job, but in cmd.exe):
using psexec, I add the user and password with the same cmdkey /add: success, I map the folder:succes, I write on that folder (using drive letter or UNC): succes - but the ERP cannot save XMLs when I add this user.
His script does not find the user and pass I've added using PSEXEC, nor can I find the user/pass when he adds them with his script.

My script shows me:

C:\Windows\system32>whoami
nt authority\system


my script runs perfectly fine
cmdkey /add successfully adds the user+pass, which survives any number of reboots, folder is accessible each time, I can write in that folder (a simple time /T).


Questions:
1. is there a difference between Service_Account: NT SERVICE\MSSQLSERVER and nt authority\system?
If so, how do I get, using PSEXEC to their user? (NT SERVICE\MSSQLSERVER)
I want to create a batch that will add the user and password on each reboot, because I do not know who really is forgetful here.

otherwise
2. Is there a way to call xp_cmdshell from outside the MSSQL server? (I do not have access to SQL server, but this xp_cmdshell seems to do the trick, while my psexec doesn't)

thank you in advance
V
 
Last edited:

Part and Inventory Search

Sponsor

Back
Top