Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 241
  • Last Modified:

MS-DOS batch file created in ASP - Can't close it.

I have this code in ASP

     Set MyFile_bat = fs.CreateTextFile(filename_bat, True)
     strLine = "C:\MiniSoft\WS92\ws92_32.exe \\cmr\scripts\mis\minisoft\" & qmake("dt") & ".s92"
     MyFile_bat.writeline strLine
***>>
     MyFile_bat.Close
            Set MyFile_bat = Nothing
-------------------------------------------------------

which creates a batch file to run something else.

I can't seem to be able to close the batch file, which is my goal.
I've tried adding another line (see ***>> above)

     MyFile_bat.writeline "exit"

- it writes 'exit', but doesn't seem to run it.

Anyone have ideas on how to close the batch file ?

Thanks.




0
tmourad
Asked:
tmourad
1 Solution
 
whammyCommented:
You shouldn't even be able to run the batch file like that, although I assume it's being created.

You need to look at Windows Scripting Host, that should solve your problem. ;-)

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/wsobjwshshell.asp
0
 
whammyCommented:
P.S. To run the batch file, just use WSHShell.run("filename") in VBScript:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/wsmthrun.asp
0
 
DRY_GINCommented:
make sure filename_bat is pointed to the folder with write access to ASP user.
If you are saying that file is created OK and just not closed (it is hard to believe that such thing can occure),
anyway - maybe you need to try different file name and write it only once, in case if some different process using this file.
or kill that file before you are creating it.
anyway if the problem only in closing - try "objectless" string:

CreateObject("Scripting.FileSystemObject").CreateTextFile(server.MapPath("/" & filename_bat), True).write("C:\MiniSoft\WS92\ws92_32.exe \\cmr\scripts\mis\minisoft\" & qmake("dt") & ".s92")

if you don't have permission to write (in my case it would be a root web folder) - you will get "Permission denided" ASP error

good luck
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
tmouradAuthor Commented:
what is interesting is if i write

  MyFile_bat.writeline "cls"

instead of
 
  MyFile_bat.writeline "exit"

it does actually clear the dos window.

so i don't get why exit wouldn't work too.
i will look further into your comments tomorrow.

thanks ! :)
0
 
DRY_GINCommented:
sorry, i completely did not your question in a first place.
Please ignore my comment.

If i got it right this time - your bat file is done, but probably cmd or other container? for the bat is still active
You can try to create VBS script instead of Bat file and check how it is working.
0
 
GaryCommented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Accept Answer by whammy

Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
GaryC123
EE Cleanup Volunteer
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now