Solved

error in moving a file using Operating System[CmdExec], sql agent service account

Posted on 2009-04-14
5
1,929 Views
Last Modified: 2012-06-21
I am trying to move a .bak file from one folder to another folder using Operating System(CmdExec), sql agent service account in configuring job step properties. In the command line, i have written move command like
ex: move "E:\foldername\*.bak" "F:\foldername"
but the job fails with the error "The process could not be created for step 1 of job 0xEA5D4EF4E6D063791FB533167 (reason: The system cannot find the file specified).
The same move command work's fine in dos command prompt.
What should i check to make sure that the system can find the file location path? or any settings to be changed to share these folders?
 
Thanks,
hari.
0
Comment
Question by:krishna_harik
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 25

Expert Comment

by:reb73
ID: 24136633
Are the drives E: and F: local non-removable drives in the server (or in other words network shares mapped as E: or F:)?

Run the following command in SQL Query window to see if the E: and F: drives appear in the list of results -

exec master..xp_fixeddrives

If they don't appear, then you have to use the full UNC path reference (\\server\share\filename.bak) in your job command.. You may also need to ensure that the SQL Agent Service account has full rights on these shares..

0
 

Author Comment

by:krishna_harik
ID: 24136860
These drives E: and F: are of local non-removable drives. i have run the command
exec master..xp_fixeddrives -- > i could see all the list of drives with available space in it.

how to check whether SQL Agent Service account has full rights on these shares?
Before doing this in production server, i want to test it in my desktop system.
0
 
LVL 25

Expert Comment

by:reb73
ID: 24137012
Actually try using the command 'move "E:\foldername\*.bak" "F:\foldername"' within a command batch file (test.bat) and call this batch file from the job step to see if it works..

0
 

Author Comment

by:krishna_harik
ID: 24137694
reb,

Thank you very much for your assistance, this worked perfectly!
please, write the commands which i need to add in creating a batch file to move the files,  like
ex:
:START
move "E:\foldername\*.bak" "F:\foldername"
IF errorlevel 1 GOTO MKFILE
GOTO :END

:MKFILE
ECHO file text>file.txt
GOTO START

:END
ECHO Quitting
PAUSE

because, this is the first time i created a batch file.
0
 
LVL 25

Accepted Solution

by:
reb73 earned 500 total points
ID: 24139019
Just a simple Move command on its own within the .bat file should suffice for what you need..

MOVE "E:\foldername\*.bak" "F:\foldername"

If there is a chance that the target file already exists, the command above will fail as it will wait for confirmation in interactive mode. If it is ok to overwrite without confirmation use the following command -

MOVE /Y "E:\foldername\*.bak" "F:\foldername"

If you need the batch file invocation to succeed regardless of whether the source file exists or not, use the IF EXIST check as follows -

IF EXIST "E:\foldername\*.bak" MOVE /Y "E:\foldername\*.bak" "F:\foldername"

The command above will move if the source file exists, and do nothing otherwise..

Optionally you can also use @ECHO OFF as the first line to prevent commands from being echoed/displayed in command window but this is not essential..
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When writing XML code a very difficult part is when we like to remove all the elements or attributes from the XML that have no data. I would like to share a set of recursive MSSQL stored procedures that I have made to remove those elements from …
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question