Run a .Bat file on the client machine

  • Thread starter Thread starter Guest
  • Start date Start date
Sure, if you can convince them to ignore all the security warnings and
install an ActiveX control that runs the batch file.
 
Not really. What business requirement are you trying to achieve with this?
Chances are, we can offer more doable alternatives.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.
 
I have to send some bytes to the COM1 port. There's a Zebra printer waiting
to print my labels there :)

The current application is a Windows app (Visual FoxPro) that opens a
command shell and TYPEs a text file (the label) to COM1. This prints the
label. I am trying to duplicate this function.

If I start a process to open a command shell, this obviously doesn't work
because it is server side code. I tried some bit of code that I found in the
user groups that used some javascript. I haven't gotten it to work, but I
would think that is the way to go, since javascript works on the client
instead of the server.

Any help would be appreciated...sonny
 
An ActiveX solution isn't out of the question. It's an internal application
for printing labels. I've never coded and ActiveX control. Do you have a
handy link showing me how its done?

thanks...sonny
 
Well, sonny, I'm still confused. You're talking about a web application
here. How is this .bat file supposed to exist on the client?

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.
 
Hi Sonny,

Dunno what language your running, but I've just written a C# ASP site that
opens word on the client machine and types in a load of labels (avery 7x3)
ready to be printed. (using VBScript for all you non-believers!)

Not sure if that's much use, but I'd have thought you could run your bat
file in a similiar way using EXEC (not sure if that's available in VBScript,
but im sure theres a way!). Or even by creating some VBScript to run some of
the WSH code here from onload()...

http://windowsitpro.com/Files/07/25285/Listing_01.txt

HTH


Dan
 
This will be an intranet application. I will be able to put the .bat file on
the client machine.
 
Hi Sonny,

No problem. Remember, it's C# :)

string wordScript;
// load word
wordScript = "<script language=\"vbscript\">\n";
wordScript += "set app = createobject(\"Word.Application\")\n";
wordScript += "set oMainDoc = app.Documents.New()\n";
wordScript += "set oSel = app.Selection\n";
wordScript += "app.Application.Visible = True\n";
// enter some text
wordScript += "oSel.TypeText \"This is some text\"\n";
wordScript += "oSel.TypeParagraph\n"; // newline
wordScript += "</script>\n";

Then you need to add any code you want to use to load the Word Mailing
Labels dialog / print / save / whatever, then call the following to make the
VBScript run...

if(!IsStartupScriptRegistered("mergeScript"))
RegisterStartupScript("mergeScript", wordScript);

Having said all that, this *might* work, although I havent tested it... Id
try it before the word thing..

string wordScript;
wordScript = "<script language=\"vbscript\">\n";
wordScript += "set objShell = CreateObject("WScript.Shell")\n";
wordScript += "set objScriptExec = objShell.Exec("c:\your.bat")\n";
wordScript += "</script>\n";
if(!IsStartupScriptRegistered("mergeScript"))
RegisterStartupScript("mergeScript", wordScript);

As I said, might work............ dunno!

HTH


Dan
 
In that case, your best bet would be to create a Windows Form or ActiveX
Control that will run in the client browser.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top