1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Batch script to change how applications open from shortcuts

Discussion in 'Windows XP' started by martinlest, Oct 28, 2011.

Thread Status:
Not open for further replies.
Advertisement
  1. martinlest

    martinlest Thread Starter

    Joined:
    Nov 11, 2010
    Messages:
    150
    Hi. I have Googled this without success. Does anyone know of a script (or is able to write one?) which will batch convert a folder (+ subfolders) full of shortcuts so that they all open the application they link to (in the case, Microsoft Flight Simulator) in a maximized, not 'normal' window?

    I have over a thousand of these shortcuts and opening each one's properties window and changing 'normal' to 'maximized' is not really an option!

    Thanks,

    Martin
     
  2. Ent

    Ent Trusted Advisor

    Joined:
    Apr 11, 2009
    Messages:
    5,467
    First Name:
    Josiah
    Batch won't handle that, but vbs may be able to. I'll see what I can cook up.
     
  3. Ent

    Ent Trusted Advisor

    Joined:
    Apr 11, 2009
    Messages:
    5,467
    First Name:
    Josiah
    The following should do what you've requested. Paste the contents of the code box into notepad, and save as MaxShortCut.vbs. The .vbs is the most important bit, if that comes out as .txt or even .bat it won't run. Place the script in the folder you want it to work against and doubleclick it to run.

    Code:
    ' 28 October 2011 - Maximize
    ' Sets the WindowStyle of all shortcut files in the current and sub directories to maximized. 
    
    Dim CFN 'Current Folder Name
    Dim CF ' Current Folder, Object
    Dim FN ' Name of the file. '
    
    Set WshShell = WScript.CreateObject("WScript.Shell")
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    
    ' Get Current Folder '
    ScriptPath = Wscript.ScriptFullName
    Set objScriptPath = objFSO.GetFile(ScriptPath)
    CFN = objFSO.GetParentFolderName(objscriptPath)
    ProcessSubFolder(objFSO.GetFolder(CFN)) ' Starts the cycle in the current folder.
    Wscript.quit
    
    
    Sub ProcessSubFolder(CF)
    Set files = CF.Files
    For each objFile In files
        FN = objFile.name
        If Lcase(right(FN,4)) = ".lnk" Then
            SetMax(CF.path & "\" & FN)
        End if 
    Next
    For each SF in CF.Subfolders
        ProcessSubFolder(SF) ' Runs against subfolder.
    Next
    End Sub
    
    Sub SetMax(SFN)
        Set objShortcut = WshShell.CreateShortcut(SFN)
        objShortcut.WindowStyle = 3
        objShortcut.Save
    End Sub
    
     
  4. martinlest

    martinlest Thread Starter

    Joined:
    Nov 11, 2010
    Messages:
    150
    Wow! Thanks so much for this: for the script AND for doing it so quickly after I posted!! I ran it with the vbs script in the folder at the top of the relevant tree: the effect was instant on 2282 shortcuts (to be precise) - and I mean instant, it must have taken a fraction of second to complete: every shortcut now shows 'Maximized' in the properties window: well, I guess they all do - I only random tested about a dozen!

    Thanks again - I really am very grateful to you. If you ever need an airport making for MS Flight Simulator as a return favour (more my line of 'programming' than vbs !!), just let me know! :)

    Martin
     
  5. martinlest

    martinlest Thread Starter

    Joined:
    Nov 11, 2010
    Messages:
    150
    I've been trying my vbs 'skills' to see if I can edit the script to reverse this - i.e. to have it convert a folder of shortcuts to open the linked programme in 'Normal Window': but I can only conclude that my 'skills' are non-existent because I can't make it work!! How would the script be in that case? Be grateful for a little more help.. Thanks,

    Martin
     
  6. Ent

    Ent Trusted Advisor

    Joined:
    Apr 11, 2009
    Messages:
    5,467
    First Name:
    Josiah
    The key line is this one:
    objShortcut.WindowStyle = 3

    The number identifies which mode it opens with.
    1 is Normal.
    3 is Maximized.
    7 is Minimized.

    I'm sure your skills are sufficient to work from there. :)
     
  7. martinlest

    martinlest Thread Starter

    Joined:
    Nov 11, 2010
    Messages:
    150
    Oh, embarrassing. I didn't know the style numbers !!!! Well, I do now ;)

    Thanks again.
     
  8. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Similar Threads - Batch script change
  1. zbo907
    Replies:
    1
    Views:
    509
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1024372

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice