Solved

ASP: Execute a .bat file that copies files

Posted on 2009-05-05
5
733 Views
Last Modified: 2012-05-06
I want to execute a bat file that contains the following line:
copy C:\Inetpub\wwwroot\test\test.txt C:\Inetpub\wwwroot\test\test2.txt

The asp page seems to execute fine without errors.

But the bat file doesnt run and create a file called "test2.txt"

What could be the problem here?
<%
	'Execute file that moves the file.
	Set WSHShell = CreateObject("Wscript.Shell")
	WSHShell.Run "C:\Inetpub\wwwroot\test\test.bat"
	set WSHShell = nothing
%>
 
Bat file

Open in new window

0
Comment
Question by:Norush
[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
  • 4
5 Comments
 
LVL 6

Expert Comment

by:DanielWillmott
ID: 24304868
How complicated is the bat file? This might done much easier inside of the ASP script.
Can you show the contents of the batch file?
0
 
LVL 6

Expert Comment

by:DanielWillmott
ID: 24304876
Oh - I see it now! :)
0
 
LVL 6

Expert Comment

by:DanielWillmott
ID: 24304888
That is easily accomplished in ASP. Of course, the process user running the ASP code will need to be able to write to the test folder.
<%
     Dim fs
     Set fs=Server.CreateObject("Scripting.FileSystemObject")
     fs.CopyFile "C:\Inetpub\wwwroot\test\test.txt","C:\Inetpub\wwwroot\test\test2.txt"
     Set fs=nothing
%> 

Open in new window

0
 
LVL 7

Author Comment

by:Norush
ID: 24304996
Thanks for your input Daniel!
But can we please keep assuming that i want to use a batchfile?

So my problem still exists. The aspcode doesnt crash but the bat file never gets executed...
0
 
LVL 6

Accepted Solution

by:
DanielWillmott earned 125 total points
ID: 24305060
I wish I could convince you otherwise as this is not best practices and could cause a host of issues both system and security.
At any rate, what is IIS running ASP as? IUSR_computername?
If so, that user needs both write and execute rights on the test folder.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

734 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