Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Administration
 ERROR ON EXEC XP_CMDSHELL NET USE

Author  Topic 

jon2371ph
Starting Member

1 Post

Posted - 2011-04-16 : 01:23:54
Hi Experts,

I have a NAS on our Network, i need to use this Network Attached Storage for our backup on SQL Database. I mapped this NAS to our SQL Server... First i enable the xp_cmdshell then i net use that NAS drive (Z Drive)...but i have some error after i Net Use this Network Drive.

Below are the Error and Query i have made..Please check my query...
--------------------------------------------------------------------
Error:
The password or user name is invalid for \\SYNOLOGY\NETBACKUP.
NULL
Enter the user name for 'SYNOLOGY':
NULL
The operation was canceled by the user.
NULL
NULL

Query i have made to enable the xp_cmdshell at sp_configure:
---------------------------------------------------------------
EXEC sp_configure 'show advanced options', 1
GO
RECONFIGURE
GO
EXEC sp_configure 'xp_cmdshell', 1
GO
RECONFIGURE
GO

query for net use the map drive z:
--------------------------------------------------
EXEC XP_CMDSHELL 'NET USE Z: \\SYNOLOGY\NETBACKUP'


I think i must include the username and password of my NAS...Hope you can help on this..

thanks,
JO

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2011-04-16 : 06:36:54
I found this:
http://www.911cd.net/forums//index.php?showtopic=15613


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

Jahanzaib
Posting Yak Master

115 Posts

Posted - 2011-04-17 : 08:06:08
First check the nework drive accessable with the user you have login on the Windows

IF NOT then check the rights of the user

IF YES then check this windows user is available in the SQL Server and it have db_backupoperator rights on a required database
and then login in sql server with this user

Regards,

Syed Jahanzaib Bin Hassan
MCTS,MCITP,OCA,OCP,OCE,SCJP,IBMCDBA

My Blog
www.aureus-salah.com
Go to Top of Page

neomancipator
Starting Member

1 Post

Posted - 2013-09-30 : 14:50:55
you will need to use credentials to access the network share. by default sql will use the account that is running the sql service.
try the following:

EXEC XP_CMDSHELL 'net use Z: \\server.domain.com\sharename password /user:domain\username'
Go to Top of Page
   

- Advertisement -