CFExecute in CF9/Windows Server 2008 R2 cannot find file

Another aggravating CF9 migration question: I'm migrating some CF sites from CF7 on Windows Server 2003 to CF9 on Windows Server 2008.  A few files have a <cfexecute> tag to kick off nbtstat.exe and write the output to a file, which then is parsed.  BUT when I try to run the page I get an error saying the file cannot be found.  The error repeats when I try to output the results to a variable, so it's not having difficulty with the output file but the nbtstat.exe.  The file exists and is referenced correctly, and other executables (like ipconfig) will work there just fine.  We've added full control to all users just to eliminate the possibility of it being a permissions issue, and the problem remains.

The code calling for <cfexecute> is attached.

What else can I try?
<cfset getname = "-A "  & #CGI.remote_host#>
<cfset nbtstattxt = "">
<cfexecute name="c:\windows\system32\nbtstat.exe" arguments="/all" variable="nbtstattxt">

Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Not sure I can help, but a few things to check:

1) Are you positive c:\windows\system32\ is the right path?

>> I get an error saying the file cannot be found
>> c:\windows\system32\

2) I know you say the *.exe exists and , but the 2 most common causes of that error are a) permissions problems and b) that the file really doesn't exist / doesn't exist at that location

>> What else can I try?

3) Do a basic DIR using cmd.exe to verify the file exists where you think it does first. Something like

<cfexecute name="c:\windows\system32\cmd.exe" arguments=" c:\windows\system32\nbtstat.exe" variable="nbtstattxt">

4) If DIR says the file exists, try calling the program with cmd.exe instead

<cfexecute name="c:\windows\system32\cmd.exe"
     arguments="/all c:\windows\system32\nbtstat.exe (... other params....)"

5) Failing that, you could also try putting the call in a .BAT file and calling the .BAT file from cfexecute.
valkyrie_ncAuthor Commented:
1.  Yes.  I can take the path directly from the CFM file and execute it on the server just fine.  
2.  It has full control for Everyone.  If there's a way to give it MORE permissions, please share 'cause I'm stumped. :P
3.  See #1
4.  If I do this, it hangs forever and six days.  I found a suggestion that adding '-inputformat none' to the cmd arguments would fix that but could not get it to work; it still times out.
5.  If I do this, it just echoes the contents of the bat file (with all the params) to the page.  If I use cmd.exe to call the bat file, it does #4.

Any other ideas?  #5 seems the best solution but until I can get it to actually execute the bat file instead of just echoing it it's kinda useless at this point.
#2 - For what it's worth, the account that matters is the one the CF Service is running under.  Usually it's SYSTEM which has limited permissions.

#4 - Add a "/c" to the beginning of "arguments".  It means execute the command then exit

ie <cfexecute  arguments="/c  c:\windows\system32\nbtstat.exe" ..... >

#5 - If changing #4 doesn't help. Can you post the cfexecute and BAT file code?
OWASP: Avoiding Hacker Tricks

Learn to build secure applications from the mindset of the hacker and avoid being exploited.

valkyrie_ncAuthor Commented:
Here are all the iterations I've tried, attached in the code snippet; the bat file code is at the bottom.  I've tried changing the user that the CF Server runs under to my login (I'm an admin and can run that file just fine via cmd prompt) and it didn't help.  Same for checking the box allowing access to the desktop to the Local Service; no dice.  LOCAL SERVICE and NETWORK SERVICE have full control of the nbtstat.exe file.

If it helps, here's the results for each iteration:

<cfexecute name="[bat file]" ... /> echoes to the browser "C:\Coldfusion9\runtime\bin>C:\Windows\System32\nbtstat.exe -A"

<cfexecute name="C:\Windows\System32\cmd.exe" arguments="-inputformat none /c C:\Inetpub\wwwroot\CFMPipeline\nbtstat.bat -A #cgi.remote_host#"... /> echoes the same to the browser as the earlier attempt

<cfexecute name="C:\Windows\System32\cmd.exe" arguments="/c C:\Windows\System32\nbtstat.exe -A #cgi.remote_host#" ... /> echoes to the browser "[empty string]"

<cfexecute name="C:\Windows\System32\cmd.exe" arguments="[bat file] -A #cgi.remote_host#" .... /> times out

<cfexecute name="C:\Windows\System32\nbtstat.exe" arguments="-A #cgi.remote_host#" ... /> gives the 'file does not exist' error.
<!---<cfexecute name="C:\inetpub\wwwroot\CFMPipeline\nbtstat.bat" timeout="5" variable="data" arguments="-A #cgi.remote_host#" />--->
<!---<cfexecute name="C:\Windows\System32\cmd.exe" timeout="5" variable="data" arguments="-inputformat none /c C:\inetpub\wwwroot\CFMPipeline\nbtstat.bat -A #cgi.remote_host#" />--->
<!---<cfexecute name="C:\Windows\System32\cmd.exe" arguments="/c C:\Windows\System32\nbtstat.exe -A #cgi.remote_host#" variable="data" timeout="5" />--->
<cfexecute name="C:\Windows\System32\cmd.exe" arguments="C:\inetpub\wwwroot\CFMPipeline\nbtstat.bat -A #cgi.remote_host#" variable="data" timeout="5" />
<!---<cfexecute name="C:\Windows\System32\nbtstat.exe" arguments="-A #cgi.remote_host#" timeout="5" variable="data" />--->
<cfdump var="#data#">

Bat File:

C:\Windows\System32\nbtstat.exe %1 %2

Open in new window

I'm not on 2008, but let me try them and see what result I get.
Both of these worked for fine me.  So if it doesn't work for you, I'm thinking it may be a permissions problem.  Any difference if you add the errorVariable OR errorFile attribute?

<cfexecute name="C:\Windows\System32\cmd.exe"
            arguments="/c C:\Windows\System32\nbtstat.exe -A"
<cfdump var="#results#">

<cfexecute name="C:\Windows\System32\cmd.exe"
            arguments="/c c:\myBATFile.bat -A"
            variable="results" />
<cfdump var="#results#">

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
valkyrie_ncAuthor Commented:
Tried errorFile, but it just gives me that oh-so-useful error in the text file.  Blech.

Good to know that you've been able to validate my tests on 2003, at least!  I think I'm going to have to redesign these pages for the affected functionality, since both I and my sys admin are thoroughly stumped.  

I'll give points on the last one, so that anyone else running across this will know there is something that works if you just  get your permissions figured out.   Thanks for the help!
valkyrie_ncAuthor Commented:
The good solutions for using cfexecute are in the accepted answer.  
You're welcome.  Wish I had access to a 2008 server so I could test it further.  On the off chance you find out anything more, let us know.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Servers

From novice to tech pro — start learning today.