Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: starting program in dos  (Read 5098 times)

0 Members and 1 Guest are viewing this topic.

mobzy

    Topic Starter


    Greenhorn

    starting program in dos
    « on: May 15, 2008, 03:54:51 AM »
    Hi guys,

    Im using windows XP.

    i am really intrested in this. I can obviously start a program in dos with start command. But, when the program starts say for example superscan, i want to be able to execute commands in the program through dos.

    for example, superscan has a command that says "lookup" and "scan" ect..  and say, another program like calc on the machine has numbers to press, i was wanting to understand a method to start commands from the actual gui of the program, from inside the dos window.

    Another great example is a port scanner. to be able to load it up which ive done, then issue a dos command to enter my ip and port and hit scan.

    can you help me? Thankyou.

    Carbon Dudeoxide

    • Global Moderator

    • Mastermind
    • Thanked: 169
      • Yes
      • Yes
      • Yes
    • Certifications: List
    • Experience: Guru
    • OS: Mac OS
    Re: starting program in dos
    « Reply #1 on: May 15, 2008, 04:07:23 AM »
    I'm a bit confused. By 'dos', do you mean Command Prompt? If so, are you trying to get it to open a program like calc and have it press the numbers for you? because that's not possible.

    mobzy

      Topic Starter


      Greenhorn

      Re: starting program in dos
      « Reply #2 on: May 15, 2008, 04:11:37 AM »
      yeah thats what i was hoping for. Or is there some 3rd party program i can use to do this?

      Carbon Dudeoxide

      • Global Moderator

      • Mastermind
      • Thanked: 169
        • Yes
        • Yes
        • Yes
      • Certifications: List
      • Experience: Guru
      • OS: Mac OS
      Re: starting program in dos
      « Reply #3 on: May 15, 2008, 04:14:35 AM »
      I don't know of a program that can do this for you but I am sure Command Prompt isn't the way to go.
      One thing I do know is you are looking for some type of script or macro. I'm afraid I don't know of any though...

      Sit tight and maybe someone will point you in the right direction.

      Sidewinder



        Guru

        Thanked: 139
      • Experience: Familiar
      • OS: Windows 10
      Re: starting program in dos
      « Reply #4 on: May 15, 2008, 05:27:01 AM »
      There are a couple of ways to do what you're asking. The first would be to send keystrokes to the application. This example uses the Windows Calc program:

      Code: [Select]
      set WshShell = WScript.CreateObject("WScript.Shell")
      WshShell.Run "calc"
      WScript.Sleep 100
      WshShell.AppActivate "Calculator"
      WScript.Sleep 100
      WshShell.SendKeys "1{+}"
      WScript.Sleep 500
      WshShell.SendKeys "2"
      WScript.Sleep 500
      WshShell.SendKeys "~"
      WScript.Sleep 500
      WshShell.SendKeys "*3"
      WScript.Sleep 500
      WshShell.SendKeys "~"
      WScript.Sleep 2500
      Source: Windows Scripting Technologies

      The other is to mimic logical mouse actions. An example was posted here

      Some applications provide their own COM objects which makes scripting the application very easy. In other situations it depends on the specific program and how it behaves in the Windows environment.

      Generally if a program presents a window and waits on the user, scripting the GUI may be possible. If a program presents a window and immediately starts doing it's thing, scripting the application probably is not possible.

      Good luck.  8)

      The true sign of intelligence is not knowledge but imagination.

      -- Albert Einstein

      Carbon Dudeoxide

      • Global Moderator

      • Mastermind
      • Thanked: 169
        • Yes
        • Yes
        • Yes
      • Certifications: List
      • Experience: Guru
      • OS: Mac OS
      Re: starting program in dos
      « Reply #5 on: May 15, 2008, 05:49:49 AM »
      Ah yes, I forgot about those.

      Just save the script Sidewinder posted as .vbs from Notepad.

      mobzy

        Topic Starter


        Greenhorn

        Re: starting program in dos
        « Reply #6 on: May 15, 2008, 07:19:56 AM »
        Thankyou for you exellent answers widewinder, you too carbon. That script works perfect. I have a slight problem tho. I want to understand how it works, because when i look at the 1+ 2 command, obviously this is + key, but what is the ~ for?

        also, when i try this on say, superscan, i start it fine and now am able to input info in the box, but what would the command be to make a button click called "Me" under the ip address i entered.


        EDIT///


        Now if i do this..

        set WshShell = WScript.CreateObject("WScript.Shell")
        WshShell.Run "scanner.exe"
        WScript.Sleep 100
        WshShell.AppActivate "scanner.exe"
        WScript.Sleep 100
        WshShell.SendKeys "me"
        WScript.Sleep 500
        WshShell.SendKeys "~"
        WScript.Sleep 500


        How would i be able to not enter any word text, but skip out the buttons and just click the "ME" button, because the above sript hits the lookup button.



        please see example below.

        http://img120.imageshack.us/img120/7543/test55hm3.jpg
        « Last Edit: May 15, 2008, 07:47:06 AM by mobzy »

        Sidewinder



          Guru

          Thanked: 139
        • Experience: Familiar
        • OS: Windows 10
        Re: starting program in dos
        « Reply #7 on: May 15, 2008, 07:47:59 AM »
        The "~" (tilde) is the enter key. A full list of the key strokes is here

        Quote
        also, when i try this on say, superscan, i start it fine and now am able to input info in the box, but what would the command be to make a button click called "Me" under the ip address i entered.

        Using only the keyboard, what actions do you have to take to give the "Me" button focus? It is these actions you need to script. Once the "Me" button has focus, sending the enter key will produce the button click.

         8)

        Note: If your application is updated, your script may break. Just something to be aware of.

        PS. I've always called the tilde a squiggle, but you won't find that in any reference.

        The true sign of intelligence is not knowledge but imagination.

        -- Albert Einstein

        Carbon Dudeoxide

        • Global Moderator

        • Mastermind
        • Thanked: 169
          • Yes
          • Yes
          • Yes
        • Certifications: List
        • Experience: Guru
        • OS: Mac OS
        Re: starting program in dos
        « Reply #8 on: May 15, 2008, 07:52:39 AM »
        Nice site, Sidewinder.

        Mobzy, I think you will want to try the following right now:

        WshShell.SendKeys "~" or WshShell.SendKeys "ENTER"
        and
        WshShell.SendKeys "TAB"

        Just imagine you don't have a mouse and you have to use your keyboard but record all the keystrokes you make and turn it into a script.

        mobzy

          Topic Starter


          Greenhorn

          Re: starting program in dos
          « Reply #9 on: May 15, 2008, 08:55:48 AM »
          Thanks for your answer and trying to help me.

          ive added:

          set WshShell = WScript.CreateObject("WScript.Shell")
          WshShell.Run "scanner.exe"
          WScript.Sleep 100
          WshShell.AppActivate "scanner"
          WScript.Sleep 100
          WshShell.SendKeys "Me"
          WScript.Sleep 100
          WshShell.SendKeys "~"
          WScript.Sleep 100
          WshShell.SendKeys "TAB"
          WScript.Sleep 2500


          and


          set WshShell = WScript.CreateObject("WScript.Shell")
          WshShell.Run "scanner.exe"
          WScript.Sleep 100
          WshShell.AppActivate "scanner"
          WScript.Sleep 100
          WshShell.SendKeys "Me"
          WshShell.SendKeys "TAB"
          WScript.Sleep 100
          WshShell.SendKeys "~"
          WScript.Sleep 100


          and still the same thing. you say imagine i have no mouse, but when i try and press keys to see what buttons activate i just hear error sounds. Am i doing it right?

          thanks again .

          mobzy

            Topic Starter


            Greenhorn

            Re: starting program in dos
            « Reply #10 on: May 15, 2008, 09:02:22 AM »
            SOMETHING great happened thanks to you sir. ill post more in a bit. i thankyou so much!!!!

            mobzy

              Topic Starter


              Greenhorn

              Re: starting program in dos
              « Reply #11 on: May 15, 2008, 09:11:15 AM »
              you way works perfect and i understand about the imagine no mouse thing :)

              i was curious, say i wanted to enter an ip into the box normally id use WshShell.SendKeys "192.168.0.1"
              WScript.Sleep 100

              how .. now this i think is confusing, would i be able to have a small dialog popup, and user enter an IP into that, and click ok, and it echos the info back into the superscan.

              hah, hard 1 ay?

              Sidewinder



                Guru

                Thanked: 139
              • Experience: Familiar
              • OS: Windows 10
              Re: starting program in dos
              « Reply #12 on: May 15, 2008, 09:34:29 AM »
              Glad you got it working.

              Quote
              how .. now this i think is confusing, would i be able to have a small dialog popup, and user enter an IP into that, and click ok, and it echos the info back into the superscan.

              Why the confusion? Typing into a small dialog popup is no different from typing into the scanner GUI.

              Quote
              hah, hard 1 ay?

              Not nearly as difficult as you might imagine. Check out this site for some ideas.

               8)
              The true sign of intelligence is not knowledge but imagination.

              -- Albert Einstein

              mobzy

                Topic Starter


                Greenhorn

                Re: starting program in dos
                « Reply #13 on: May 15, 2008, 09:45:54 AM »
                thanks for advice above mate, ill check it out in a bit.

                I need some help guys.

                if used TAB to cycle through menus, and also ctrl+tab..
                i found more menus, n cant seem to get anywhere, no commands seem to work to cycle through. any idears?

                maybe they arnt true gui buttons, but they link to say, start scan and they scan. ( not superscan ). Ive hiy a brick wall!:(

                any ideas? id really appreciated it!!!

                « Last Edit: May 15, 2008, 10:56:23 AM by mobzy »

                Sidewinder



                  Guru

                  Thanked: 139
                • Experience: Familiar
                • OS: Windows 10
                Re: starting program in dos
                « Reply #14 on: May 15, 2008, 12:21:57 PM »
                The plot thickens. With Windows objects, this can be accomplished by first writing a script to display all the verb names for an object and their values. With this information, you can work backwards to script the GUI. This was demonstrated in the second example.

                If your application supplied a COM object, you may have to research either the registry or an object browser for the program id and go from there.

                The sendkeys method has codes for almost every key or key combination except PRNTSCRN. You'll have to manually go through the key sequences needed to accomplish your task and then script every single keystroke. This can be a bit tedious so check out if your application has command line parameters where you can accomplish your task from the command prompt.

                If you give us more info on the superscan program, exact name and version, perhaps one the the members will have some experience with this specific software.

                Good luck.  8)
                The true sign of intelligence is not knowledge but imagination.

                -- Albert Einstein