Batch file run from Railo won't xcopy

60 views
Skip to first unread message

Dave Merrill

unread,
Feb 23, 2012, 1:35:52 PM2/23/12
to ra...@googlegroups.com
I have a windows batch file that among other things copies a directory to another location. When I run it from a dos prompt, it works as expected, but using cfexecute from Railo, the main xcopy call that starts the whole process copies 0 files.

I've tried having Railo run as me (I have god rights), and disabling my antivirus, no change. I haven't tried disabling User Account Control (win 7 pro), because that's not a great solution for the different machines where this will have to run (and also because I don't really want to restart my computer just to test that).

Wouldn't you think that the cmd process launched by Railo would run as the same user Railo itself is running as?

Any other thoughts? 

Thanks,
Dave

Lyle Karstensen

unread,
Feb 23, 2012, 1:40:18 PM2/23/12
to ra...@googlegroups.com

Make sure your Railo service is using a login with the correct credentials. If you are staring Railo from the command line then you need to make sure the command line is running as admin.

 


 

Lyle Karstensen Jr.
Chief Executive Officer  (CEO)

Description: Description: Logo

Phone: 702.940.4200
Fax:
702.940.4201
Direct: 702.932.8200
Cell: 702.683.3666
Email: ly...@realistiq.com
Website: http://www.realistiq.com

Peter Boughton

unread,
Feb 23, 2012, 1:58:53 PM2/23/12
to ra...@googlegroups.com
If you are specifying relative paths with xcopy, you need to make sure
you are in the correct directory first.

Dave Merrill

unread,
Feb 23, 2012, 2:07:36 PM2/23/12
to ra...@googlegroups.com
Thanks for jumping in, but as I said, Railo is now logging in as me, and running that file from a dos prompt as me works fine. Don't know what more I can do to ensure it has admin credentials at the windows level.

Dave

Dave Merrill

unread,
Feb 23, 2012, 2:09:38 PM2/23/12
to ra...@googlegroups.com
Good thought, but they're all absolute paths, passed in  from Railo  as cmd line arguments. I can see the readout of the cmds in the file as it runs, and not only does it look correct, I can copy the offending line of code and paste it into a dos prompt and it works.

Dave

Viktor Krasynskyy

unread,
Feb 23, 2012, 2:23:20 PM2/23/12
to ra...@googlegroups.com
Maybe you did not escape everything that needs to be escaped. Can you post actual code so I can try in on my Railo installation?

Dave Merrill

unread,
Feb 23, 2012, 3:13:06 PM2/23/12
to ra...@googlegroups.com
Thanks for replying. It's hard to pull out just these pieces to post them here in a way that'd be runnable.

But if you're talking about escaping within the .bat, it runs fine from the cmd line, so I think things are escaped ok. Also, I've temporarily hard coded the paths I'm passing in from Railo, to make sure it's not a parameter passing problem.

If you're talking about escaping elsewhere, please what you mean.

Thanks,
Dave

Viktor Krasynskyy

unread,
Feb 23, 2012, 3:29:36 PM2/23/12
to ra...@googlegroups.com
I just tried small POC and it worked well:

mycopy.bat:

xcopy /S /Y c:\railo-src c:\railo-dst

test_xcopy.cfm:

<cfset Command = GetDirectoryFromPath(GetCurrentTemplatePath()) & "mycopy.bat">
<cfexecute name="#Command#" variable="exeResVar" timeout="3600"></cfexecute>
<cfdump var="#exeResVar#">

I'm not sure how close it is to what you are trying to do. If nothing works you can try to use SysInternals tools (procmon) to monitor access to files.

Dave Merrill

unread,
Feb 23, 2012, 3:57:56 PM2/23/12
to ra...@googlegroups.com
Turns out you hit this on the head. There was an exclude file used, given only as a file name. It's in the directory with the batch file that uses it, but apparently that's not sufficient. Making it an absolute path fixed the xcopy call.

This is one thing Iv'e always disliked about batch files -- crappy error reporting. It took 10 seconds to fix, once I knew where to look...

Dave

Dave Merrill

unread,
Feb 23, 2012, 4:00:10 PM2/23/12
to ra...@googlegroups.com
Just to be clear, I replied to Peter's post about checking for relative paths, but it's not showing up that way.

Dave

Peter Boughton

unread,
Feb 23, 2012, 6:00:57 PM2/23/12
to ra...@googlegroups.com
Dave wrote:
> Just to be clear, I replied to Peter's post about checking for relative
> paths, but it's not showing up that way.

That's because google groups are email-based lists, which by their
nature can't be threaded, so you need to quote when it's not otherwise
clear who you're replying to.


Glad it turned out to be this simple though - was starting to wonder
wtf else it could be. :)

Reply all
Reply to author
Forward
0 new messages