By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,636 Members | 1,213 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,636 IT Pros & Developers. It's quick & easy.

Script to open a DOS Command Window and run exe on client (INTRANET)

P: n/a
Hi,

I have an asp.net app running on an Intranet. From one of my aspx
pages I would like to run a javascript that will run the following
command OUTSIDE of the IIS/asp.net environment on the CLIENT machine
(remember, a controlled Intranet!). Is this possible? This windows
program needs to be opened and data entered periodically while using
the asp.net app as well.

The exe runs in a dos command window, tied to a Citrix ica file.

C:\Program Files\Citrix\ICA Client\wfica32.exe ciq.ica

PLEASE help me...the boss really wants this!

Thanks,

Kathy
Jul 20 '05 #1
Share this Question
Share on Google+
11 Replies


P: n/a
In article <75**************************@posting.google.com >,
Ka**********@attbi.com enlightened us with...
Hi,

I have an asp.net app running on an Intranet. From one of my aspx
pages I would like to run a javascript that will run the following
command OUTSIDE of the IIS/asp.net environment on the CLIENT machine
(remember, a controlled Intranet!). Is this possible?


You can use an HTA for this (jscript or vbscript).
They run on the client.

"Normal" javascript, as in just a link to the application/exe or a
window.open, would require a browser environment.
You could have a link in the aspx page that points to your hta, which
opens the process and shows the dos window.

<a href="myHTA.hta">Click here for process</a>

HTA documentation:
http://msdn.microsoft.com/workshop/a...taoverview.asp

--
--
~kaeli~
I do whatever my Rice Krispies tell me to.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 20 '05 #2

P: n/a
Lee
KathyB said:

Hi,

I have an asp.net app running on an Intranet. From one of my aspx
pages I would like to run a javascript that will run the following
command OUTSIDE of the IIS/asp.net environment on the CLIENT machine
(remember, a controlled Intranet!). Is this possible? This windows
program needs to be opened and data entered periodically while using
the asp.net app as well.

The exe runs in a dos command window, tied to a Citrix ica file.

C:\Program Files\Citrix\ICA Client\wfica32.exe ciq.ica

PLEASE help me...the boss really wants this!

IE only:
var shell=new ActiveXObject("WScript.Shell");
shell.Run("cmd /K CD C:\ & Dir", 1);

peeve:
It is not "a javascript", any more than a Java program is "a Java".

Jul 20 '05 #3

P: n/a
Lee, I tried this but get an IE6 error that a ";" is expected...at
position 15 but that doesn't make sense.

Specifically, from an onclick event in aspx page, I have

Response.Write("<script>var shell=new
ActiveXObject(""WScript.Shell"");shell.Run(""cmd /K CD C:\\Program
Files\\Citrix\\ICA Client\\wfica32.exe ciq.ica"", 1);</script>")

I see the script in the html source when I run it, but I get the error
as mentioned above. Any thoughts?

Thanks for your help.

Kathy

p.s. what does the "1" do at the end of the shell.run line?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #4

P: n/a
kaeli,

First, I trust anyone who listens to their rice krispies!

Although I've never used it, this seems like a great idea. I created an
hta page (that I open from the button onclick event in aspx page) and
put in an onload javascript:

function openCIQ() {
var shell=new ActiveXObject("WScript.Shell");
shell.Run("C:\\Program Files\\Citrix\\ICA Client\\wfica32.exe ciq.ica",
1); }

I get prompted for the File Download (Open/Save, etc.)

When clicked, I get an error message that the ica file can not be found.
I suspect it's looking for the file on my http local host instead of the
c: directory?

Anyhow, any ideas of where I may be going wrong?

Thanks again.

Kathy

Kathy

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #5

P: n/a
In article <3f***********************@news.frii.net>, kathyburke40
@attbi.com enlightened us with...
kaeli,

First, I trust anyone who listens to their rice krispies!

hehe

function openCIQ() {
var shell=new ActiveXObject("WScript.Shell");
shell.Run("C:\\Program Files\\Citrix\\ICA Client\\wfica32.exe ciq.ica",
1); }

I get prompted for the File Download (Open/Save, etc.)

Try
var shell = WScript.CreateObject("Wscript.Shell");
instead of ActiveX. With an HTA, you don't need ActiveX. Less overhead,
I think, too.
When clicked, I get an error message that the ica file can not be found.
I suspect it's looking for the file on my http local host instead of the
c: directory?

Anyhow, any ideas of where I may be going wrong?


It's an oddity with the quotes because of the space in the "Program
Files".
In VBScript, I'd do
shell.Run """C:\\Program Files\\Citrix\\ICA Client\\wfica32.exe
ciq.ica"""

I'm not sure how it goes in JScript. If you can't get it, get the space
out using DOS filename for Program Files with the tilde.

--
--
~kaeli~
I do whatever my Rice Krispies tell me to.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 20 '05 #6

P: n/a
Lee
Kathy Burke said:

Lee, I tried this but get an IE6 error that a ";" is expected...at
position 15 but that doesn't make sense.

Specifically, from an onclick event in aspx page, I have

Response.Write("<script>var shell=new
ActiveXObject(""WScript.Shell"");shell.Run(""cm d /K CD C:\\Program
Files\\Citrix\\ICA Client\\wfica32.exe ciq.ica"", 1);</script>")

I see the script in the html source when I run it, but I get the error
as mentioned above. Any thoughts?

Thanks for your help.

Kathy

p.s. what does the "1" do at the end of the shell.run line?


In Javascript, you don't nest quotes by doubling them, as you do in VBScript.
Try changing ""WScript.Shell"" to \"Wscript.Shell\"
and the same for the other embedded quotes.
You'll also have to escape every backslash, so all of those instances
of \\ need to change to \\\\

The "1" argument says to show the DOS window:
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/wsmthrun.asp>

Jul 20 '05 #7

P: n/a
In article <MP************************@nntp.lucent.com>,
ti******@NOSPAM.comcast.net enlightened us with...
>


It's an oddity with the quotes because of the space in the "Program
Files".
In VBScript, I'd do
shell.Run """C:\\Program Files\\Citrix\\ICA Client\\wfica32.exe
ciq.ica"""

I'm not sure how it goes in JScript. If you can't get it, get the space
out using DOS filename for Program Files with the tilde.

This worked for me with VBScript. If all your users have IE, VBScript is
fine.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<TITLE>Run Executable HTA</TITLE>
</HEAD>
<body bgcolor=#565656>
<script language="VBScript" type="text/vbscript">
set oShell = CreateObject("WScript.Shell")
oShell.run """C:\Program Files\Microsoft Office\Office\Excel.exe""",1
window.close
</script>
</BODY>
</HTML>
This worked with javascript.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<TITLE>Run Executable HTA</TITLE>
</HEAD>
<body bgcolor=#565656>
<script language="javascript" type="text/javascript">
var oShell = new ActiveXObject("WScript.Shell");
var prog = "C:\\Program Files\\Microsoft Office\\Office\\Excel.exe";
oShell.run ('"'+prog+'"',1);
window.close();
</script>
</BODY>
</HTML>

--
--
~kaeli~
If a book about failures doesn't sell, is it a success?
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 20 '05 #8

P: n/a
kaeli,

Tried the changes you suggested. Now I get an error that "WScript is
undefined". I've also changed over to using DOS filename.

From the examples I've found on line, this seems like it should work...

sigh...?

Kathy

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #9

P: n/a
Hi again,

Seems to work, but can't find the file. However, when I copy and paste
the file name (as shown below) into the cmd window, it runs the program
as expected.

(note \\ used for javascript)

"c:\\Progra~1\\Citrix\\ICAACLI~1\\wfica32 vbciq.ica"

Does anyone have any idea of where I can look next?

Thanks again.

Kathy

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #10

P: n/a
Ah ha!

Oddly enough I had to set a variable with the full file path for the
target file.

var file = "c:\\progra~1\\Citrix\\ICACLI~1\\vbciq.ica"

oShell.Run("c:\\progra~1\\Citrix\\ICACLI~1\\wfica3 2 " + file,1);

That did it. Thanks for all the help!

Kathy

p.s. I thought using an HTA would mean I WOULDN'T get the open/save
confirmation window when this loads. Any way around that?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #11

P: n/a
In article <3f***********************@news.frii.net>, kathyburke40
@attbi.com enlightened us with...

p.s. I thought using an HTA would mean I WOULDN'T get the open/save
confirmation window when this loads. Any way around that?


No. According to MS site on HTAs, it is designed that way for security.
--
--
~kaeli~
When you choke a smurf, what color does it turn?
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 20 '05 #12

This discussion thread is closed

Replies have been disabled for this discussion.