www.webdeveloper.com
Results 1 to 6 of 6

Thread: Passing Variables to the Command Line

  1. #1
    Join Date
    Jul 2014
    Posts
    3

    Passing Variables to the Command Line

    Hello all,

    I'm new to JavaScript so bear with me. I am sending a command to windows CMD line which is working. However I want to change the username and password in the command to variables within my script. I can't seem to find any syntax anywhere that allows me to do so. Here's what I when it's hard-coded without variables:

    Sys.OleObject("Wscript.Shell").Run('cmd /k(cd c:\\"Program Files (x86)\"\\TheFolder\\program client & program SETWORKINGFOLDER "$//Test Complete Scripts" "C:\\dave" -host 192.222.22.226 -user "Johndoe" -password "mypassword" -repository "RepoFolder" & program GET -host 192.168.254.226 -user "Johndoe" -password "mypassword" -repository "RepoFolder" "$//Test Complete Scripts" -merge overwrite -setfiletime current)');

    for the variables I've tried this:

    var userName = '"Johndoe"';
    Sys.OleObject("Wscript.Shell").Run.................-user %userName

    any help is appreciated! thanks!

  2. #2
    Join Date
    May 2014
    Posts
    911
    Quote Originally Posted by beCool View Post
    I am sending a command to windows CMD line which is working.
    Shouldn't be... that should be blocked outright... lemme guess, IE8 or earlier?

    Really what you are doing is something that JavaScript shouldn't even have access to in the first place. Completely the wrong language for the job, and if what you have there actually works, you've got a security hole on your system the size of the USS IOWA.
    Java is to JavaScript as Ham is to Hamburger.

  3. #3
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,348
    WScript is not JavaScript.
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

  4. #4
    Join Date
    Jul 2014
    Posts
    3
    lol! The script is not manipulating a browser nor is it built into a site. It is being used in a testing software. It is simply getting the latest files from a repository. WScript works with JavaScript apparently. All I need to know is what to put around the variable in order for the command line to be able to recognize it as a variable.

  5. #5
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,348
    Of sorts, more like JScript than JavaScript.
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

  6. #6
    Join Date
    Jul 2014
    Posts
    3
    Sooooo, anyone have any ideas? Technically what i'm using is JScript. It's used in a testing software that can run desktop, mobile and web applications. In this situation I'm simply using the CMD prompt to refresh a program that get's the latest files from a shared server. Any help is greatly appreciated.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles