WScript.Shell Problem

Jan 31, 2007

Trying to open a file on a network drive when user clicks an HTML button on a web page. When page loads, there is an error that states there's an invalid character on the line where I declare my variable. When I click the button, the error changes to "Object expected" but is on a line nowhere near any scripting or any HTML code related to scripting. Does my code look correct or no?

And, yes my button is calling the function on the "onclick" and "filepath" from VB code does have a value when I do a view source on the page.

<script language="javascript" type="text/javascript">
function OpenFile(){
var x = new ActiveXObject("WScript.Shell");
x.run(<%=filepath %>);
}
</script>

View 11 Replies


ADVERTISEMENT

Encrypting JS Code On Wscript

Jul 20, 2005

Is it possible to encrypt/protect a source code of Javascript to be
run on WSCRIPT (not on a webpage)?

View 1 Replies View Related

WScript Syntax For Creating A New Document Based On A Word Template

Dec 1, 2005

I want my (IE) Intranet users to be able to create a new Word document
based on a specified template.

The following works, but I would like to be able to pass the filename
as a parameter, as there are often multiple documents on the same page:

---------------Script Code Starts-------------
<script lang="Javascript1.2">

function NewDoc()
{
var oShell
oShell = new ActiveXObject ("WScript.Shell");
oShell.Run('cmd /K "C:Test.dot"', 0, false);
window.event.cancelBubble = true;
return false;
}
</script>
---------------Script Code Ends-------------


---------------Link Code Starts-------------
<a href=":" onclick="return NewDoc()">Create a new document based on
C:Test.dot</a>
---------------Link Code Ends--------------

I know to specify the document template name as follows:

---------------Link Code Starts-------------
<a href=":" onclick="return NewDoc('C:Test.dot')">Create a new
document based on C:Test.dot</a>
---------------Link Code Ends--------------

And change the "Function NewDoc()" in the script code to line to
"Function NewDoc(TemplateName)". The problem is that I don't know what
syntax to use to parametise the
"oShell.Run('cmd /K "C:Test.dot"', 0, false);"
line.

View 1 Replies View Related

Shell-like Case

Feb 20, 2007

In Bourne shell, you can do:

case ($x) in
foo*)
;;
*bar)
;;
esac

so that the first case matches any string starting with "foo", the
second any string ending in "bar", etc. In Tcl, you can:

switch -glob $x {
"foo*" {
}
"*bar" {
}
}

and accomplish the same thing. I'm struggling to do that in
JavaScript. switch seems to follow C semantics and do a full-length
match. And String.match() doesn't seem to do glob-style matching so I
can't do:

if ($x.match("foo*")) {
...

Is there a way to match on patterns in a JavaScript control structure?

View 7 Replies View Related

Unix Shell In A Web Broswer?

May 30, 2007

For those of you who know what JS/UIX is, its a UN*X-like OS for standard web-browsers....

View 3 Replies View Related

How To Tell What Is Running On Shell In UNIX

Jul 29, 2010

How can you tell what shell you are running on UNIX system?

View 1 Replies View Related

Bourne Shell Or Tcl Style Loop In JavaScript?

Nov 12, 2007

In Bourne shell, you can do

Code:
for x in `foo bar grill` ; do
echo $x
done
and in Tcl I can do:


Code:
foreach e in { foo bar grill} {
put $e
}
but in JavaScript, I end up doing:


Code:
var l = [ 'foo', 'bar', 'grill' ];
for (var i in l) {
var x = l[i];
... do something with x...
}
Is there an idiom for looping over a fixed list of things in JavaScript that doesn't require creating a var before the loop?

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved