Using VBS to open a program in XP

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Z1P2
    New Member
    • Sep 2007
    • 23

    Using VBS to open a program in XP

    Someone suggested a while back that I should use VBscript shell to open programs in windows XP and set them in specific locations on the desktop with specific window sizes. However, I have never worked with vbscript before, and do not understand it at all. I'm pretty quick to pick things up though, and if I saw an example of a VBS startup script, I could adapt it for my needs. Can anyone point me to a working vbs script that starts a program in windows xp?
  • kadghar
    Recognized Expert Top Contributor
    • Apr 2007
    • 1302

    #2
    Originally posted by Z1P2
    Someone suggested a while back that I should use VBscript shell to open programs in windows XP and set them in specific locations on the desktop with specific window sizes. However, I have never worked with vbscript before, and do not understand it at all. I'm pretty quick to pick things up though, and if I saw an example of a VBS startup script, I could adapt it for my needs. Can anyone point me to a working vbs script that starts a program in windows xp?
    Hi, sure...

    First of all, make sure the Shell command is in a Sub procedure, then just run it. Its quite simple,

    Note that Shell will return a Double (a number), this number is your program ID.

    [CODE=vb]Sub forZ1P2()
    Dim a As Double
    a = Shell("c:\windo ws\notepad.exe" , 1)
    End Sub[/CODE]

    now, you have notepath open, and 'a' has its ID.

    well, i hope that helps.

    Comment

    • Z1P2
      New Member
      • Sep 2007
      • 23

      #3
      I don't understand how that sets the specific window location and size on the desktop when the program is launched...

      Comment

      • kadghar
        Recognized Expert Top Contributor
        • Apr 2007
        • 1302

        #4
        Originally posted by Z1P2
        I don't understand how that sets the specific window location and size on the desktop when the program is launched...
        the second parameter of shell will set the windows size, i used the numeric value ('1'), but there are constants easier to remember.

        once you have the handler number ('a') you can easily work with it.

        Comment

        Working...