Go Back   Velocity Reviews > Newsgroups > ASP Net
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

ASP Net - Run a .Bat file on the client machine

 
Thread Tools Search this Thread
Old 01-25-2005, 08:33 PM   #1
Default Run a .Bat file on the client machine


Is there a way to do it?

thx...sonny


=?Utf-8?B?c29ubnk=?=
  Reply With Quote
Old 01-25-2005, 08:46 PM   #2
Ken Cox [Microsoft MVP]
 
Posts: n/a
Default Re: Run a .Bat file on the client machine

Sure, if you can convince them to ignore all the security warnings and
install an ActiveX control that runs the batch file.

"sonny" <> wrote in message
news:3BD50343-A3BA-4AE3-871B-...
> Is there a way to do it?
>
> thx...sonny


  Reply With Quote
Old 01-25-2005, 09:29 PM   #3
Kevin Spencer
 
Posts: n/a
Default Re: Run a .Bat file on the client machine

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.

"sonny" <> wrote in message
news:3BD50343-A3BA-4AE3-871B-...
> Is there a way to do it?
>
> thx...sonny



  Reply With Quote
Old 01-25-2005, 11:27 PM   #4
=?Utf-8?B?c29ubnk=?=
 
Posts: n/a
Default Re: Run a .Bat file on the client machine

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
"Kevin Spencer" wrote:

> 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.
>
> "sonny" <> wrote in message
> news:3BD50343-A3BA-4AE3-871B-...
> > Is there a way to do it?
> >
> > thx...sonny

>
>
>

  Reply With Quote
Old 01-25-2005, 11:31 PM   #5
=?Utf-8?B?c29ubnk=?=
 
Posts: n/a
Default Re: Run a .Bat file on the client machine

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

"Ken Cox [Microsoft MVP]" wrote:

> Sure, if you can convince them to ignore all the security warnings and
> install an ActiveX control that runs the batch file.
>
> "sonny" <> wrote in message
> news:3BD50343-A3BA-4AE3-871B-...
> > Is there a way to do it?
> >
> > thx...sonny

>
>

  Reply With Quote
Old 01-26-2005, 01:20 PM   #6
Kevin Spencer
 
Posts: n/a
Default Re: Run a .Bat file on the client machine

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.

"sonny" <> wrote in message
news:E114E5C3-8F9E-41A7-B715-...
>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
> "Kevin Spencer" wrote:
>
>> 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.
>>
>> "sonny" <> wrote in message
>> news:3BD50343-A3BA-4AE3-871B-...
>> > Is there a way to do it?
>> >
>> > thx...sonny

>>
>>
>>



  Reply With Quote
Old 01-26-2005, 01:49 PM   #7
=?Utf-8?B?ZGhucml2ZXJzaWRl?=
 
Posts: n/a
Default Re: Run a .Bat file on the client machine

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


"sonny" wrote:

> 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
> "Kevin Spencer" wrote:
>
> > 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.
> >
> > "sonny" <> wrote in message
> > news:3BD50343-A3BA-4AE3-871B-...
> > > Is there a way to do it?
> > >
> > > thx...sonny

> >
> >
> >

  Reply With Quote
Old 01-26-2005, 02:03 PM   #8
=?Utf-8?B?c29ubnk=?=
 
Posts: n/a
Default Re: Run a .Bat file on the client machine

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

"Kevin Spencer" wrote:

> 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.
>
> "sonny" <> wrote in message
> news:E114E5C3-8F9E-41A7-B715-...
> >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
> > "Kevin Spencer" wrote:
> >
> >> 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.
> >>
> >> "sonny" <> wrote in message
> >> news:3BD50343-A3BA-4AE3-871B-...
> >> > Is there a way to do it?
> >> >
> >> > thx...sonny
> >>
> >>
> >>

>
>
>

  Reply With Quote
Old 01-26-2005, 02:19 PM   #9
=?Utf-8?B?c29ubnk=?=
 
Posts: n/a
Default Re: Run a .Bat file on the client machine

Dan,

Could you show me an example of what you did? I would appreciate it.


"dhnriverside" wrote:

> 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
>
>
> "sonny" wrote:
>
> > 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
> > "Kevin Spencer" wrote:
> >
> > > 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.
> > >
> > > "sonny" <> wrote in message
> > > news:3BD50343-A3BA-4AE3-871B-...
> > > > Is there a way to do it?
> > > >
> > > > thx...sonny
> > >
> > >
> > >

  Reply With Quote
Old 01-26-2005, 02:31 PM   #10
=?Utf-8?B?ZGhucml2ZXJzaWRl?=
 
Posts: n/a
Default Re: Run a .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

"sonny" wrote:

> Dan,
>
> Could you show me an example of what you did? I would appreciate it.
>
>
> "dhnriverside" wrote:
>
> > 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
> >
> >
> > "sonny" wrote:
> >
> > > 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
> > > "Kevin Spencer" wrote:
> > >
> > > > 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.
> > > >
> > > > "sonny" <> wrote in message
> > > > news:3BD50343-A3BA-4AE3-871B-...
> > > > > Is there a way to do it?
> > > > >
> > > > > thx...sonny
> > > >
> > > >
> > > >

  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump