Solved

ASP: Execute a .bat file that copies files

Posted on 2009-05-05
5
725 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

930 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now