?
Solved

ASP: Execute a .bat file that copies files

Posted on 2009-05-05
5
Medium Priority
?
738 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 375 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

762 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