ASP: Execute a .bat file that copies files

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

Who is Participating?

Improve company productivity with a Business Account.Sign Up

DanielWillmottConnect With a Mentor Commented:
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.
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?
Oh - I see it now! :)
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

NorushAuthor Commented:
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...
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.