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
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 SQL Job and cmdExec question

Author  Topic 

drewsalem
Constraint Violating Yak Guru

304 Posts

Posted - 2008-03-12 : 08:01:14
Hi,

Not sure whether to post this here or as a .net thread. I'll try here first.

I've written a .net app that will compress back up files and then delete files in the directory as according to a retension parameter in a config file eg "3 days". This config file is in the same directory that the executable is in. When run via the command prompt/windows, it correctly locates the config file in the current directory and works correctly. However if run as a cmdExec step in a sql server job, it errors with the following message:

Message
Executed as user: ...\Administrator. ... System.IO.FileNotFoundException: Could not find file 'C:\WINNT\system32\Config.ini'...


It's looking for the config file (as if defaulting) in the system32 directory and not in the current directory of the executable as specified in the code. The owner of the job is sa.

Any ideas?

Drew

Drew
---------------------
"It's Saturday night; I've got no date, a two litre bottle of Shasta, and my all-Rush mix tape... LET'S ROCK."

drewsalem
Constraint Violating Yak Guru

304 Posts

Posted - 2008-03-12 : 10:07:26
If I hardcode the correct path, it works. Is it possible that cmdexec is run from the system32 folder and so runs the executable from there. If this is the case, the it's rather naff!

Drew
---------------------
"It's Saturday night; I've got no date, a two litre bottle of Shasta, and my all-Rush mix tape... LET'S ROCK."
Go to Top of Page

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2008-03-12 : 23:20:08
Yes, you need to set current path.
Go to Top of Page

drewsalem
Constraint Violating Yak Guru

304 Posts

Posted - 2008-03-13 : 05:43:23
That's really bad. If my executable is say on the E drive, but cmdExec runs it from the system32 folder, then the current path will always be the system32 folder. It doesn't matter where my executable is originally.

Drew
---------------------
"It's Saturday night; I've got no date, a two litre bottle of Shasta, and my all-Rush mix tape... LET'S ROCK."
Go to Top of Page
   

- Advertisement -