473,322 Members | 1,347 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,322 software developers and data experts.

Dos commands in JavaScript - pass command line arguments to batch file

Hi,

I wanted to know how to run dos commands using javascript.
Also i need to run a batch file with two command line arguments. These commandline arguments are variables.

Thanks

Raghu
Dec 28 '07 #1
12 20416
Hi,

I was able to run a batch file using vb script.
Expand|Select|Wrap|Line Numbers
  1. Set WshShell = CreateObject("WScript.Shell")
  2. WshShell.Run"setcpath2.bat"
  3.  
i need to pass command line arguments to the batch file. This is stored in variables.

Thanks,
Raghu
Dec 28 '07 #2
acoder
16,027 Expert Mod 8TB
See if this thread offers any help.

I trust you know that this will not be possible with JavaScript, but you could use ActiveX/ vbscript for an IE-only solution with the correct security settings.
Dec 28 '07 #3
Thanks for the reply. Is it possible to pass values to the batch file from vb script?
The values are basically the path that needs to be set that varies.
Dec 30 '07 #4
acoder
16,027 Expert Mod 8TB
I'm not sure, but could you not include it within the string (separated by a space)?

You my also want to try asking the Visual Basic forum.
Dec 30 '07 #5
Hi,

I need to pass two strings to a batch file using vb script. I am able to call the batch file using wshShell.Run, but am unable to pass any arguments.
Expand|Select|Wrap|Line Numbers
  1. Dim WshShell
  2. Set WshShell = CreateObject("WScript.Shell")
  3. dim pos
  4. pos=InstrRev(full,"\")
  5. dim fpath
  6. dim pl
  7. pl= Len(full)-pos-1
  8. fpath= Left(full,pl)
  9. dim fname 
  10. dim flen
  11. flen= Len(full)-pos
  12. fname=Right(full,flen)
  13. Alert(fpath)
  14. Alert(fname)
  15. WshShell.Run "setcpath2.bat"
  16.  
I need to pass fname and fpath as the two arguments to the batch file.
I would appreciate any help with this.

Raghu
Jan 2 '08 #6
Thanks for your help. Appreciate it.

Raghu
Jan 2 '08 #7
Hi,

I have a similar query. How do i pass a variable as the argument to the batch file.

Expand|Select|Wrap|Line Numbers
  1. var shell = new ActiveXObject("WScript.Shell");
  2. var fname;
  3. var fpath;
  4. shell.run( '"setcpath2.bat"  fpath fname' , 1, true );
  5.  
The two arguments are fpath and fname. I need the values stored in the variables to be passed as arguments.

Thanks,
Raghu
Jan 2 '08 #8
acoder
16,027 Expert Mod 8TB
Threads merged.
Jan 2 '08 #9
acoder
16,027 Expert Mod 8TB
I assume you'd use something like:
Expand|Select|Wrap|Line Numbers
  1. var shell = new ActiveXObject("WScript.Shell");
  2. var fname = ... // set these to something
  3. var fpath = ...
  4. shell.run( '"setcpath2.bat" ' + fpath + ' ' + fname, 1, true );
  5.  
Jan 2 '08 #10
Thanks a ton!!! It works.
Appreciate it.

Raghu
Jan 3 '08 #11
acoder
16,027 Expert Mod 8TB
You're welcome. Post again if you have any more questions and we'll be glad to help.
Jan 3 '08 #12
acoder
16,027 Expert Mod 8TB
Split and merged posts from Pass Parameter to .exe thread, so that question and answer appears in one thread.

MODERATOR
Jan 3 '08 #13

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: David Carroll | last post by:
I'm at my wits end with this silly thing. I'm new to python, so please excuse my impending ignorance ;). I am trying to execute a command, and get the output back into a string variable. Here's...
12
by: Moosebumps | last post by:
So, after reading some messages about os.system, and looking at the popen stuff and trying it a bit, I still have not found a way to keep a command window open for several commands (on Windows...
8
by: Sir_Scriptor | last post by:
Hi, I am trying to understand Batch files for logging Text. I have a general understanding, but I am little lost on some of the command strings I keep seeing. I went out and Bought Microsoft Windows...
1
by: Dennis Gaida | last post by:
Hi there, I want to upload some exported reports to a FTP Server, for this I use a command line FTP utility. My Database sits in C:\Documents and Settings\Dennis\My Documents\Database The FTP...
6
by: Shooter4Life8 | last post by:
Hi, I am having trouble figureing out the best way to open a command prompt then write lines to it in VB.NET. Currently I have this code, but it execute's too fast I think because Dim psi As...
2
by: gopal | last post by:
static void Main(string args) { .... .... } I have an EXE now. I am now giving one of the arguments as
18
by: tcurdts | last post by:
I think what I’m trying to do is very basic but I’m a rank beginner and I’m stuck. I’m using Python 2.4.1 on WindowsNT. I’ve installed UnxUtils, which includes the tar commands for Windows. ...
1
by: stemp1ar | last post by:
I am wondering if it possible to open a single process and run multiple commands on that process and check standard error and standard out after each command? Has anyone done something similar...
5
by: JOHNSHELL08 | last post by:
sir , i saw many batch file which contains the first line @ ECHO OFF WHAT THIS LINE DOES & WHAT ITS IMPORTANCE IN BATCH FILE. AND ALSO TELL ME................. How can we execute a single...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.