By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,948 Members | 852 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,948 IT Pros & Developers. It's quick & easy.

Using VBS to open a program in XP

P: 23
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?
Apr 26 '08 #1
Share this Question
Share on Google+
3 Replies


kadghar
Expert 100+
P: 1,295
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.

Expand|Select|Wrap|Line Numbers
  1. Sub forZ1P2()
  2. Dim a As Double
  3. a = Shell("c:\windows\notepad.exe", 1)
  4. End Sub
now, you have notepath open, and 'a' has its ID.

well, i hope that helps.
Apr 28 '08 #2

P: 23
I don't understand how that sets the specific window location and size on the desktop when the program is launched...
Jun 26 '08 #3

kadghar
Expert 100+
P: 1,295
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.
Jun 26 '08 #4

Post your reply

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