Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 2008
»
SQL Server 2008 - General
»
xp_cmdshell
12 posts, Page 1 of 2
1
2
»»
xp_cmdshell
Rate Topic
Display Mode
Topic Options
Author
Message
zouzou
zouzou
Posted Thursday, December 13, 2012 4:04 AM
Grasshopper
Group: General Forum Members
Last Login: Tuesday, May 14, 2013 10:23 AM
Points: 22,
Visits: 190
Hello there,
i would like to delete all the files in a directory in another server using xp_cmdshell
EXEC xp_cmdshell 'FORFILES /p \\t-fc-fim\logs /m *.* /d -30 /c "CMD /C del /Q /F @FILE"'
i get an error ERROR: UNC paths (\\machine\share) are not supported.
what can i do to make this work ?
your help is much appreciated.
Thank you
Post #1396102
anthony.green
anthony.green
Posted Thursday, December 13, 2012 4:08 AM
SSCertifiable
Group: General Forum Members
Last Login: Friday, April 12, 2013 3:51 AM
Points: 5,075,
Visits: 4,831
You cannot use UNC paths in a CMD window.
Try mapping the UNC path as a mapped drive or use SSIS with a file system task.
Want an answer fast? Try here
How to post data/code for the best help - Jeff Moden
Need a string splitter, try this - Jeff Moden
How to post performance problems - Gail Shaw
CrossTabs-Part1
&
Part2 - Jeff Moden
SQL Server Backup, Integrity Check, and Index and Statistics Maintenance - Ola Hallengren
Managing Transaction Logs - Gail Shaw
Troubleshooting SQL Server: A Guide for the Accidental DBA - Jonathan Kehayias and Ted Krueger
Post #1396104
zouzou
zouzou
Posted Thursday, December 13, 2012 4:16 AM
Grasshopper
Group: General Forum Members
Last Login: Tuesday, May 14, 2013 10:23 AM
Points: 22,
Visits: 190
I mapped the network drive in sql sevrer box and i have ran this
EXEC xp_cmdshell 'FORFILES /p I:\ /m *.* /d -30 /c "CMD /C del /Q /F @FILE"'
ERROR: The specified directory does not exist.
Post #1396105
muthukkumaran Kaliyamoorthy
muthukkumaran Kaliyamoorthy
Posted Thursday, December 13, 2012 4:29 AM
Ten Centuries
Group: General Forum Members
Last Login: Monday, May 13, 2013 4:17 AM
Points: 1,123,
Visits: 4,422
fhfh (12/13/2012)
I mapped the network drive in sql sevrer box and i have ran this
EXEC xp_cmdshell 'FORFILES /p I:\ /m *.* /d -30 /c "CMD /C del /Q /F @FILE"'
ERROR: The specified directory does not exist.
I hope you might know the risk about cmdshell. You can use the 'Net use with uname and password' to access the share.
Muthukkumaran Kaliyamoorthy
Helping SQL DBAs and Developers >>>
SqlserverBlogForum
Post #1396113
Illwill
Illwill
Posted Thursday, December 13, 2012 4:31 AM
SSC-Enthusiastic
Group: General Forum Members
Last Login: Tuesday, April 30, 2013 6:23 AM
Points: 198,
Visits: 271
sounds user profile related, are you mapping it as a persistent mapping with the same account as the sql-server is running (I'm not sure this will work, but it might)
Post #1396114
zouzou
zouzou
Posted Thursday, December 13, 2012 4:40 AM
Grasshopper
Group: General Forum Members
Last Login: Tuesday, May 14, 2013 10:23 AM
Points: 22,
Visits: 190
Do you know what is the syntax of NET use in my scenario ?
Post #1396121
zouzou
zouzou
Posted Thursday, December 13, 2012 4:41 AM
Grasshopper
Group: General Forum Members
Last Login: Tuesday, May 14, 2013 10:23 AM
Points: 22,
Visits: 190
tried to map the network drive with username and password but no luck
Post #1396122
Hemant.R
Hemant.R
Posted Thursday, December 13, 2012 5:47 AM
SSC Rookie
Group: General Forum Members
Last Login: Thursday, May 16, 2013 7:29 AM
Points: 45,
Visits: 171
hi,
please refer below link, it will help u.
http://www.howtogeek.com/118452/how-to-map-network-drives-from-the-command-prompt-in-windows/
Post #1396138
muthukkumaran Kaliyamoorthy
muthukkumaran Kaliyamoorthy
Posted Thursday, December 13, 2012 7:29 AM
Ten Centuries
Group: General Forum Members
Last Login: Monday, May 13, 2013 4:17 AM
Points: 1,123,
Visits: 4,422
fhfh (12/13/2012)
Do you know what is the syntax of NET use in my scenario ?
http://www.sqlservercentral.com/Forums/Topic667056-145-1.aspx#bm1027279
Muthukkumaran Kaliyamoorthy
Helping SQL DBAs and Developers >>>
SqlserverBlogForum
Post #1396186
Robert klimes
Robert klimes
Posted Thursday, December 13, 2012 8:27 AM
SSC Eights!
Group: General Forum Members
Last Login: 2 days ago @ 1:55 PM
Points: 888,
Visits: 1,848
anthony.green (12/13/2012)
You cannot use UNC paths in a CMD window.
Just for clarification, You can use UNC paths in a CMD windows. It is FORFILES that does not allow UNC paths.
Bob
-----------------------------------------------------------------------------
http://www.sqlservercentral.com/articles/Best+Practices/61537/
Post #1396224
« Prev Topic
|
Next Topic »
12 posts, Page 1 of 2
1
2
»»
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.