SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Administration
 ERROR ON EXEC XP_CMDSHELL NET USE
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

jon2371ph
Starting Member

Pakistan
1 Posts

Posted - 04/16/2011 :  01:23:54  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

Germany
8764 Posts

Posted - 04/16/2011 :  06:36:54  Show Profile  Visit webfred's Homepage  Reply with Quote
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

Pakistan
115 Posts

Posted - 04/17/2011 :  08:06:08  Show Profile  Visit Jahanzaib's Homepage  Reply with Quote
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

Edited by - Jahanzaib on 04/17/2011 08:09:46
Go to Top of Page

neomancipator
Starting Member

1 Posts

Posted - 09/30/2013 :  14:50:55  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000