Batch script to change how applications open from shortcuts

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

martinlest

Thread Starter
Joined
Nov 11, 2010
Messages
153
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
 

Ent

Josiah
Retired Trusted Advisor
Joined
Apr 11, 2009
Messages
5,467
Batch won't handle that, but vbs may be able to. I'll see what I can cook up.
 

Ent

Josiah
Retired Trusted Advisor
Joined
Apr 11, 2009
Messages
5,467
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
 

martinlest

Thread Starter
Joined
Nov 11, 2010
Messages
153
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
 

martinlest

Thread Starter
Joined
Nov 11, 2010
Messages
153
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
 

Ent

Josiah
Retired Trusted Advisor
Joined
Apr 11, 2009
Messages
5,467
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. :)
 

martinlest

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

Thanks again.
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

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 807,865 other people just like you!

Latest posts

Staff online

Members online

Top