
Creating folders in startmenu?
Kevin, here is a solution I wrote for one of my WSH books. Sorry, all
comments are in German - I just installed Linux on my other machine,
so I can't enter currently my English language samples. But I guess the
code is understandeable.
'************************************************
' File: Startmenu.vbs (WSH-Beispiel in VBScript)
' Autor: Gnter Born
'
' Zweck: Das Beispiel richtet eine Verknpfung zum
' Windows-Editor in der Startmengruppe Born ein.
'************************************************
Option Explicit
Dim Text, Titel
Dim WSHShell ' Objektvariable
Dim status, Ready_txt
Dim Shortcut, Path
Ready_txt = "Es wurde eine Verknpfung zum Editor im Startmen
eingerichtet."
' Benutzermeldung mit Abfrage, ob Verknpfung erstellt werden darf.
Text = "Tr?gt den Windows-Editor im Startmen in der Gruppe ""Born"" ein."
Titel = "WSH-Beispiel - by Gnter Born"
status = MsgBox(Text, _
vbOKCancel + vbInformation, _
Titel)
If (status <> vbOK) Then
WScript.Quit 1 ' Benutzer hat Abbrechen gew?hlt
End if
' Erstelle neues WSHShell-Objekt, welches wir zum Zugriff
' auf das WshSpecialFolders-Objekt brauchen.
Set WSHShell = WScript.CreateObject("WScript.Shell")
' Jetzt holen wir den Pfad zum Ordner "Startmenu/Programme". Dieser
' l?sst sich ber das WshSpecialFolders-Objekt abfragen.
Path = WSHShell.SpecialFolders("Programs")
' Wichtig: Der Eintrag soll in Programme\Born kommen
Path = Path & "\Born\"
' Prfe, ob Pfad existiert, sonst Gruppe anlegen
MakePath Path
' Da wir den Pfad zum Startmen kennen, l?sst sich die
' CreateShortcut-Methode fr die Verknpfung nutzen.
' Erzeuge als erstes das neue Objekt "Shortcut".
Set Shortcut = WSHShell.CreateShortcut (Path & "Editor.lnk")
' Jetzt mssen wir noch die Verknpfungseigenschaften setzen.
' Erst kommt die Angabe fr das Zielverzeichnis.
Shortcut.TargetPath = _
WSHShell.ExpandEnvironmentStrings("%windir%\Notepad.exe")
' Nun legen wir das Arbeitsverzeichnis fest.
Shortcut.WorkingDirectory = _
WSHShell.ExpandEnvironmentStrings("%windir%")
' Fensterstil 1 = normal, 3 = maximiert, 7 = minimiert
Shortcut.WindowStyle = 1
' Das Symbol fr die Verknpfung angeben.
Shortcut.IconLocation = _
WSHShell.ExpandEnvironmentStrings("%windir%\Notepad.exe, 0")
' Die Tastenkombination (Hotkey) festlegen.
Shortcut.Hotkey = "Alt+Ctrl+E"
Shortcut.Save ' Jetzt wird die Verknpfung angelegt
WScript.Echo Ready_txt ' Abschlussmeldung
WScript.Quit ' Skript beenden
Sub MakePath (pathx)
' Erzeuge den Ordner, falls diese nicht vorhanden ist.
Dim fso, f
On Error Resume Next
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.CreateFolder(pathx)
Set fso = Nothing
Set f = Nothing
End Sub
'*** Ende
G. Born
Check out the WSH Bazaar at:
www.borncity.de
Quote:
>I know that I must be able to do this since I can create lnk's in the menu,
>but for the life of me I just can't figure this one out. anyone out there
>that can maybe supply some information, I would thanks.
>Kevin Sweet