Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

link open a file and redirect 1

Status
Not open for further replies.

faver

MIS
Apr 5, 2007
11
US
Hello,

I have been trying for a few hors and I cannot come up with an easy answer.
I have a form, when it gets submited it goes to a new page on this new page I put a button that when clicked it opens a batch file up to this point everything works well.

I would like to add a script that once you click the button it opens the batch file and it redirects the page to another web page. Can this be done I was trying this

Code:
 <p><a href="finishing.bat" onclick="default.asp">
    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="[URL unfurl="true"]http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0"[/URL] width="100" height="22">
      <param name="movie" value="button1.swf" />
      <param name="quality" value="high" />
      <embed src="button1.swf" quality="high" pluginspage="[URL unfurl="true"]http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"[/URL] type="application/x-shockwave-flash" width="100" height="22"> </embed>
    </object>
  </a></p>
but this just opens my bat file
 
What exactly does your batch file do? Depending on it's environment, you can put the redirect as the last line in your batch file.

[monkey][snake] <.
 
the batch file opens a barcode program which gets data from the web form
something like

bcode.bat
Code:
cd
barcode
cd 
bartend
BarTend /f=ms /pd /x

how would I do a redirect on a batch file?
 
Try this (untested)

Code:
<a href="finishing.bat" onclick="window.location='default.asp'">

[monkey][snake] <.
 
unfortunatelly I tried that and did not work
 
I got one more trick up my sleeve.

Make a javascript function like this:
Code:
<script type="text/javascript">
   var shellObject = new ActiveXObject("wscript.Shell");

   function runBat() {
      shellObject.run("finishing.bat")
   }
</script>

Make your anchor object this:
Code:
<a href="default.asp" onclick="runBat()">

you may have to put the entire path in the shellObject.run statement for the batch file, I'm not 100% sure.

[monkey][snake] <.
 
I just tested this with sample data and it did work, it does have the activeX warning though.

[monkey][snake] <.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top