Solved

ASP: Execute a .bat file that copies files

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Welcome, welcome!  If you are new to the series and haven't been following along, please take a brief moment to review the first three installments: Part 1 (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/A_266-VBScri…
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…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

707 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

11 Experts available now in Live!

Get 1:1 Help Now