Creating folders in startmenu? 
Author Message
 Creating folders in startmenu?

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



Sun, 22 Sep 2002 03:00:00 GMT  
 Creating folders in startmenu?
Get the path to the start menu with (WScript) Shell.SpecialFolders(), and use (Scripting)
FileSystemObject.CreateFolder()...

--
Michael Harris
MVP Scripting

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



Sun, 22 Sep 2002 03:00:00 GMT  
 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



Mon, 23 Sep 2002 03:00:00 GMT  
 Creating folders in startmenu?
Thanks a bunch it really help.  Both Michael and Gunter, you guys are great
 Thanks again


Tue, 24 Sep 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. create a folder or find default temp folder

2. Create new folder in current folder in explorer window

3. linkplace in startmenu

4. linkplace in startmenu

5. Disable Startmenu during logon.

6. Adding entrys in Startmenu from VB

7. Creating / Deleting Folders and files

8. Create web folder via script?

9. how to create hylerlink to file on network folder

10. Creating shared folder on a remote server

11. Create folders only 1 at a time

12. Creating a Folder

 

 
Powered by phpBB® Forum Software