automation with VBS

Posted on 2005-04-09
Last Modified: 2011-09-20

I know how to write a script that open an internet explorer window with VBS and set its size, etc... I was wondering how I could do it with other applications in windows.  Mostly, what I need is a way to open up Windows Explorer windows to certain folders and arrange them in a certain way so I organize files (an upload I do every day).

It seems there is a class automation list somewhere that apps have to be added to.  Can someone get me started with a script that will open a windows explorer window to C:\WINDOWS\ and size it to 200x200 and place it at location (0,0) on my screen?  Once I have it, I think I'll be able to change the destination folders, sizes, and locations, etc, to what I really need.  Also, where can I find what options I have available for each application I could startup using VBS?  

Thanks experts!

Question by:meuedyn
    LVL 38

    Expert Comment

    Explorer does not expose any automation objects.  You can make do with some basic command line switches, but you will not be able to move windows around within a VB Script.  This is probably closest to what you are trying to achieve.

    Set WshShell = WScript.CreateObject("WScript.Shell")
    WshShell.Run "%windir%\explorer /e,c:\winnt\", 9

    >Also, where can I find what options I have available for each application I could startup using VBS?  
    Generally that information is available in the online help for that application.  All MS Office applications are capable of being automated for example, and you have the option when installing of installing their VBA help as well so that you can look up the object model.  It is worth noting that most programs do not expose any automation at all.  
    LVL 38

    Assisted Solution

    Sorry, you asked for C:\Windows:

    Set WshShell = WScript.CreateObject("WScript.Shell")
    WshShell.Run "%windir%\explorer /e,c:\Windows\", 9
    LVL 14

    Accepted Solution

    You can use the internet object to achieve that:

    Dim X
    Set X = CreateObject("internetexplorer.application")
        X.navigate "c:\Windows\"
        X.Visible = True
        X.Width = 200
        X.Height = 200
        X.Left = 0
        X.Top = 0
    Set X = Nothing

    Author Comment

    Is there anyway that I can write a script, batch file, whatever, you name it.. that can open up, lets say, notepad, to a specific size and location?  It would be great to double-click a single icon and have 3 apps open into preset window sizes/locations..

    LVL 38

    Assisted Solution

    Not in VBS.  You could use a third party scripting solution like WinBatch or write your own Visual Basic program to do this.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
    Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
    Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now