Solved

Access and edit users' Start Menu entries in VBScript login script

Posted on 2008-10-06
2
885 Views
Last Modified: 2012-05-05
As part of our login script, there is a part to clean up the Start Menu for each user, as we have several Windows XP workstations running on a Windows Server 2003 network. Currently I'm using a batch file as the login script, but I'm in the process of converting it all to a VBScript, to allow for additional functionality in setting up Outlook and printers based on AD credentials.

The script should be able to:
1) Delete the Outlook Express shortcut, if found, from a user's Start Menu folder;
2) Delete the Sophos folder (if found) from the All Users Start Menu;
3) Set the Hidden attribute on both Startup folders; and
4) Sort the order of the Start Menu.

Attached is what I have so far this in a batch file; I am struggling to replicate this functionality in VBScript, but have encountered problems as I can't seem to find a way of accessing the %userprofile% equivalent in VBScript, just the absolute path (which obviously won't work for a login script).
if exist "%USERPROFILE%\Start Menu\Programs\Outlook Express.lnk" (
del /q "%USERPROFILE%\Start Menu\Programs\Outlook Express.lnk"
)
if exist "C:\Documents and Settings\All Users\Start Menu\Programs\Sophos\" (
rd /s /q "C:\Documents and Settings\All Users\Start Menu\Programs\Sophos\"
)
attrib +H "%USERPROFILE%\Start Menu\Programs\Startup\" /S
attrib +H "C:\Documents and Settings\All Users\Start Menu\Programs\Startup\" /S
REGPERM /K HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\MenuOrder /A:Everyone:R /Q

Open in new window

0
Comment
Question by:skrysiak
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 38

Accepted Solution

by:
Shift-3 earned 250 total points
ID: 22650853
Paste the script below into a text file with a .vbs extension.  Running it should accomplish the desired objectives.


Set objShell = CreateObject("WScript.Shell")
strAllUsersProfile = objShell.ExpandEnvironmentStrings("%allusersprofile%")
strUserProfile = objShell.ExpandEnvironmentStrings("%userprofile%")
 
Set objFSO = CreateObject("Scripting.FileSystemObject")
 
If objFSO.FileExists(strUserProfile & "\Start Menu\Programs\Outlook Express.lnk") Then
    objFSO.DeleteFile strUserProfile & "\Start Menu\Programs\Outlook Express.lnk", True
End If
 
If objFSO.FolderExists(strAllUsersProfile & "\Start Menu\Programs\Sophos") Then
    objFSO.DeleteFolder strAllUsersProfile & "\Start Menu\Programs\Sophos", True
End If
 
If objFSO.FolderExists(strUserProfile & "\Start Menu\Programs\Startup") Then
    Set objStartup = objFSO.GetFolder(strUserProfile & "\Start Menu\Programs\Startup")
    objStartup.Attributes = 19
End If
 
If objFSO.FolderExists(strAllUsersProfile & "\Start Menu\Programs\Startup") Then
    Set objStartup = objFSO.GetFolder(strAllUsersProfile & "\Start Menu\Programs\Startup")
    objStartup.Attributes = 19
End If
 
objShell.Run "REGPERM /K HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\MenuOrder /A:Everyone:R /Q"

Open in new window

0
 

Author Closing Comment

by:skrysiak
ID: 31503426
Sweet! Works perfectly, thanks for your help.
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Issue: Unstable cursor in Windows XP and Windows runs extremely slow in that any click will bring up the Hour glass (sometimes for several seconds before giving you what you want) . Troubleshooting Process and the FINAL FIX: This issue see…
If you have done a reformat of your hard drive and proceeded to do a successful Windows XP installation, you may notice that a choice between two operating systems when you start up the machine. Here is how to get rid of this: Click Start Clic…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…

718 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