Mark M.
Mark M.

Reputation: 11

HTA Application For Desktop Windows - How to make a button to Run a BAT File

I am an IT tech and have created some cool BAT file/scripts to aid in our work. Some fixes and such. I was interested in create some sort of launch pad of buttons that will display a nice GUI of choices (buttons). I have my PNG file buttons already but cannot figure out how to link the PNG file to run a ".bat" when clicked.

I know how to hyperlink the PNG to a website or something, but I want to link it to a .bat file.

For example: Lets say I have a fix for software called ABC. I have a button (PNG) created already that says "ABC Fix".

I'd like to create a menu with the ABC Fix button on it. When you click the ABC Fix button, it launches the .bat which runs the scripted fix.

I'm currently using HTML and saving an HTA file. If there are better methods, please let me know.

Thanks!

(I hope that makes sense)

Upvotes: 1

Views: 1161

Answers (1)

junkfoodjunkie
junkfoodjunkie

Reputation: 3178

First... why are you using images for buttons? Use CSS. There isn't really EVER a reason to make a button an image.

That being said, what you need to do is forget about the buttons, make it an <a> tag and link to the bat-file. Then style that <a> to look like whatever you want it to look like.

Something like this:

a {
  display: block;
  background: blue;
  color: white;
  border: 2px solid lightblue;
  max-width: 6em;
  text-align: center;
  padding: .5em;
  border-radius: .5em;
  }
a:hover {
  background: lightblue;
  border-color: blue;
  }
<a href="c:\link-to-file.bat">ABC fix</a>

Upvotes: 1

Related Questions