Solved

ASP: Execute a .bat file that copies files

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

808 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