473,386 Members | 1,815 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Using jscript for logon script

I have written a jscript that is executed when the user logs into the
network. Among other things, I want the script to be able to run an
executable which is stored on the network. Can anyone tell me the proper
syntax for this? I think the line, WshShell.Run, is to be used but unsure
of how it would be written.

Thank You
Jul 20 '05 #1
3 4535
On Tue, 05 Aug 2003 22:14:51 GMT, Andrew <be********@rogers.com> wrote:
I have written a jscript that is executed when the user logs into the
network. Among other things, I want the script to be able to run an
executable which is stored on the network. Can anyone tell me the proper
syntax for this? I think the line, WshShell.Run, is to be used but
unsure
of how it would be written.


Here's an example of how to use a shell object, in this case to execute a
"net send" and check if the execution was successful:

var oShell = new ActiveXObject("WScript.Shell");
....
var cmd = "%ComSpec% /c net send " + machine + " \"" + msg + "\"";
var windowReturnCode = oShell.Run(cmd, 0, true);

var statusmessage = "Failed to send message\r\n";
switch (windowReturnCode) {
case 0 : statusmessage = "Message successfully sent"; break;
case 2 : statusmessage += "The computer could not be found on the
network."; break;
default : statusmessage += "Error code: " + windowReturnCode;
}
....

Adapt it for your own needs and add a liberal sprinkling of try and
catches. The switch is acting on the return code that the shell received
upon execution of the command.

More details in the Windows Script Host docs that are buried somewhere on
Microsft's MSDN site.
--
Andrew Urquhart
- http://www.andrewu.co.uk/clj.asp
- FAQ for comp.lang.javascript by Jim Ley at http://jibbering.com/faq
- Archive at http://groups.google.com/groups?grou...ang.javascript
Jul 20 '05 #2
I used x.Run(\\\\server\\share\\filename);

This works fine, however, I also need to pass some parameters encased in
double quotes. The above statement doesn't allow more than the two already
used. This is the statement I am trying to call accross the network:

\\server\share\filename "\\server\share\filename -
s -f1\\server\share\filename -f2\c:filename"

When I use the above in a .bat file it works great. The problem is finding
the right syntax to do the same thing in a .js file

Any help would be appreciated...sorry about double posting. I didn't
realize there was this group at first.


"Evertjan." <ex**************@interxnl.net> wrote in message
news:Xn********************@194.109.133.29...
Andrew wrote on 06 aug 2003 in comp.lang.javascript and seperately in
microsoft.public.scripting.jscript:
I have written a jscript that is executed when the user logs into the
network. Among other things, I want the script to be able to run an
executable which is stored on the network. Can anyone tell me the
proper syntax for this? I think the line, WshShell.Run, is to be used
but unsure of how it would be written.


Please never multipost !

Crossposting is ok.

Now you have two people giving the same help.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Jul 20 '05 #3
> I used x.Run(\\\\server\\share\\filename);

This works fine, however, I also need to pass some parameters encased
in double quotes. The above statement doesn't allow more than the
two already used. This is the statement I am trying to call accross
the network:

\\server\share\filename "\\server\share\filename -
s -f1\\server\share\filename -f2\c:filename"

When I use the above in a .bat file it works great. The problem is
finding the right syntax to do the same thing in a .js file


You can just use single quotes to enclose a string literal that includes
double quotes as in:

'this thing "that thing"'

So that would mean (all on one line)...

x.Run('\\\\server\\share\\filename
"\\\\server\\share\\filename -s -f1\\\\server\\share\\filename -f2
c:filename"');

--
Michael Harris
Microsoft.MVP.Scripting
Seattle WA US

Technet Script Center
http://www.microsoft.com/technet/scr...er/default.asp

Microsoft® Windows®2000 Scripting Guide
http://www.microsoft.com/technet/scr...s_overview.asp

Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Al | last post by:
Hi, I am trying to add rows to a table dynamically, using JScript. Can I someone explain, how to add events to the newly added cells/ rows? Following code does not fire the onmousemove event. ...
2
by: collie | last post by:
Hi, I have 2 listboxes. The first gets populated from the db as soon as the page loads. The second listbox get populated based on the user's selection from the first listbox. However,...
21
by: hemant.singh | last post by:
Hello all, I am try'g to send window.location.href to the server script who will generate dynamic javascript according to the referral name comg in as param Now bcz <script language="javascript"...
8
rcollins
by: rcollins | last post by:
I am not sure if I am in the right place, but maybe someone can help me anyway. I am trying to map a printer by using the IP address in my logon script. I had it set up from the print server...
2
by: rodentboy | last post by:
I am trying to write a logon script in windows 2000 group policy that will archive the users .pst files to a share on the network. We already have a general.bat logon script that maps to the users...
2
by: sunsoffun | last post by:
Im trying to hide a menu column using jscript. Its works as required in firefox but ie.. a big no no. Please see the code below.... <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0...
1
by: sunsoffun | last post by:
Im trying to hide a menu column using jscript. Its works as required in firefox but ie.. a big no no. Please see the code below.... <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0...
9
AnuSumesh
by: AnuSumesh | last post by:
Hi All, I have one dll written in c#. One of its methods return array of dictionary. I want to call and use that method in ASP file. I am using jscript in ASP. my code is a s follows: <%...
0
by: visweswaran2830 | last post by:
Hi, I want to Create Logon script using vbscript to install software in remote system.
0
by: shadows88 | last post by:
Hi can anybody help me whit a logon script I need to : add a ip network printer not installed on a server but ip based, ip 10.100.50.25 printer Brother HL-2170W
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.