NTDOCAdministrator
(KiX Master)
2002-10-11 09:37 AM
ModifyStartMenu()

;FUNCTION ModifyStartMenu()
;
;ACTION Modifies the Start Menu and Taskbar options
;
;AUTHOR NTDOC
;
;HELP BY: Bryce wrote code to update binary values.
;
;SYNTAX None
;
;PARAMETERS $regstring[52] = "06"
; $regstring[8] = "06"
; Selects which binary value to edit - see table
; $regstate[32]="00"
; Sets XP Menu Style - see table
;
;RETURN 0 if successful, otherwise error code
;
;REMARKS Please read all documentation for options
;
;KIXTART VER 4.12
;
;DEPENDENCIES Latest version of WMI and KiXtart 4.12
;
;TESTED ON Windows 98SE, NT, 2000, XP
;
;EXAMPLE $ReturnCode=ModifyStartMenu
;
;KIXTART BBS http://www.kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000279
;
;Documentation and Code below

Modifying the Start Menu Options via KiXtart

In order to modify the Start Menu Options via a Regedit or programmatically
you need to make the modification first, then either log off or end task the
shell (explorer.exe) and your new settings will take affect. The reason is
that these settings appear to first be stored in volatile memory and are
then written to the Registry when you log off. The GUI apparently makes
some kind of undocumented API call to have Explorer reload its settings,
which you are not able to do with a simple Regedit change. There also
appears to be a state that can't be achieved via the GUI, which is to use
the Classic Menu and Small Icons, but can be done via Regedit.

Windows XP: Shell State XP Menu or Classic Menu
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer
ShellState
Reg_Binary - The 33rd binary value controls this state.
00=Classic Menu 02=XP Menu

Windows XP: Large/Small Icons
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced
Start_LargeMFUIcons
DWORD 1 Enables large icons 0 Disables large icons when using the XP Menu and
not the Classic Menu. The Classic Menu does not use the Start_LargeMFUIcons
settings

Windows XP: Lock the Taskbar Menu
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced
TaskbarSizeMove
DWORD 1 Disables locking the taskbar 0 Enables locking the taskbar

Windows XP: Group Similar Tasbar Buttons
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced
TaskbarGlomming
DWORD 1 Enables grouping similar buttons 0 Disables grouping similar buttons

Windows Start Menu options are controlled by the following Registry locations.
Windows 2000 and XP use the 9th binary value and Windows NT uses the 53 binary
value as shown in the table below.

Windows 2000 and XP
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects2
Settings
Windows NT 4.0
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects
Settings
Windows 9x
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects
Settings

SINGLE OPTIONS:
08 = No Settings Enabled
09 = Auto Hide
00 = Show Clock
0A = Always on Top
0C = Show small icons in Start Menu

MULTIPLE OPTIONS:
01 = Auto Hide and Show Clock
02 = Always on Top and Show Clock
03 = Always on Top and Auto Hide and Show Clock
04 = Show small icons in Start Menu and Show Clock
0E = Always on Top and Show small icons in Start Menu
0F = Always on Top and Auto Hide and Show small icons in Start Menu
06 = Always on Top and Show small icons in Start Menu and Show Clock
07 = All Options Enabled
0B = Always on Top and Auto Hide
0D = Auto Hide and Show small icons in Start Menu


 Code:
Function ModifyStartMenu()
dim $ars, $i, $count, $settings, $x
If @INWIN=1
    $ARS = writevalue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon","AutoRestartShell","1","REG_DWORD")
EndIF
Select
    Case @PRODUCTTYPE="Windows 95"
        $settings = readvalue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects","settings")
    Case @PRODUCTTYPE="Windows 98"
        $settings = readvalue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects","settings")
    Case @PRODUCTTYPE="Windows Me"
        $settings = readvalue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects","settings")
    Case @PRODUCTTYPE="Windows NT Workstation"
        $settings = readvalue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects","settings")
    Case @PRODUCTTYPE="Windows 2000 Professional"
        $settings = readvalue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects2","settings")
    Case @PRODUCTTYPE="Windows XP Professional"
        $settings = readvalue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects2","settings")
    Case 1
        Return
EndSelect

Dim $regstring[(len($settings)/2)-1]

for $i = 1 to len($settings) step 2
    $regstring[$count] = substr($settings,$i,2)
    $count = $count + 1
next

Select
    Case @PRODUCTTYPE="Windows 95"
        $regstring[8] = "06"
        $x = writevalue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects","settings",join($regstring,""),"REG_BINARY")
    Case @PRODUCTTYPE="Windows 98"
        $regstring[8] = "06"
        $x = writevalue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects","settings",join($regstring,""),"REG_BINARY")
    Case @PRODUCTTYPE="Windows Me"
        $regstring[8] = "06"
        $x = writevalue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects","settings",join($regstring,""),"REG_BINARY")
    Case @PRODUCTTYPE="Windows NT Workstation"
        $regstring[52] = "06"
        $x = writevalue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects","settings",join($regstring,""),"REG_BINARY")
    Case @PRODUCTTYPE="Windows 2000 Professional"
        $regstring[8] = "06"
        $x = writevalue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects2","settings",join($regstring,""),"REG_BINARY")
    Case @PRODUCTTYPE="Windows XP Professional"
        $regstring[8] = "06"
        $x = writevalue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects2","settings",join($regstring,""),"REG_BINARY")
    Case 1
        Return
EndSelect

If @PRODUCTTYPE="Windows XP Professional"
    $state = readvalue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer","shellstate")
Dim $regstate[(len($state)/2)-1]
$count = 0
For $i = 1 to len($state) step 2
    $regstate[$count] = substr($state,$i,2)
    $count = $count + 1
next
    $regstate[32]="00" ; 00=Classic Menu  02=XP Menu
    ; Start_LargeMFUIcons value of 1=Use Large Icons in XP Menu 0=Use Small Icons in XP Menu
    $x = WriteValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "Start_LargeMFUIcons","0", "REG_DWORD")
    $x = writevalue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer","shellstate",join($regstate,""),"REG_BINARY")
Endif
$COMPUTER=@WKSTA
$PROC = "EXPLORER.EXE"
For each $Process in GetObject("winmgmts:{impersonationLevel=impersonate}!//$COMPUTER").ExecQuery("select * from Win32_Process where Name='$PROC'")
    $x=$Process.Terminate
Next
If @INWIN=2
    Run "Explorer"
Endif
EndFunction


 Code:
OPTIONS TABLE
SINGLE OPTIONS:
08 = No Settings Enabled
09 = Auto Hide
00 = Show Clock
0A = Always on Top
0C = Show small icons in Start Menu

MULTIPLE OPTIONS:
01 = Auto Hide and Show Clock
02 = Always on Top and Show Clock
03 = Always on Top and Auto Hide and Show Clock
04 = Show small icons in Start Menu and Show Clock
0E = Always on Top and Show small icons in Start Menu
0F = Always on Top and Auto Hide and Show small icons in Start Menu
06 = Always on Top and Show small icons in Start Menu and Show Clock
07 = All Options Enabled
0B = Always on Top and Auto Hide
0D = Auto Hide and Show small icons in Start Menu



MightyR1
(MM club member)
2002-10-11 09:43 AM
Re: ModifyStartMenu()

Looks Nice...

Will try now


NTDOCAdministrator
(KiX Master)
2002-10-11 09:50 AM
Re: ModifyStartMenu()

Hey guys maybe post comments in this post. UDF forum is for the UDF only, not to discuss it.

http://www.kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=14&t=000057&p=2#000046

Lonkero, I'm not sure what you mean with your last comment.


Schuliebug
(Hey THIS is FUN)
2002-10-17 01:18 PM
Re: ModifyStartMenu()

Great UDF, thankz ! Solves my issue

Lee Wilmott
(Starting to like KiXtart)
2002-11-29 01:06 AM
Re: ModifyStartMenu()

NTDOC,

This UDF is absolutely brilliant...very helpful to me indeed.

There is only one comment (if I may; sorry)!

I really don't like the idea of "blowing" away explorer and then reloading it. You end up loosing icons in your system tray...(maybe not the end of the world, but I was hoping for a more elegant way!). [Smile]

Do you, or anyone else know of a way to reload the shell/start menu?

I tried looking on Microsoft's website and all I came up with was this...http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/objects/shell/refreshmenu.asp. Which I "tried" but I didn't get very far with it. [Frown]

Is the method you perform in this UDF the only solution?

Cheers, thanks for the UDF,

Lee


Les
(KiX Master)
2002-11-29 01:34 AM
Re: ModifyStartMenu()

I haven't tested this UDF but to refresh the desktop you might try:

$RC=SetFocus("")
$RC=SendKeys("{F5}")


NTDOCAdministrator
(KiX Master)
2002-11-29 02:59 AM
Re: ModifyStartMenu()

Sorry F5 will not refresh the menu, it will actually do the opposite, it will make it lose the changes.

Microsoft calls an API call to reload the settings from a dynamic cache. This is also accomplished by logging off and then back on.

So until KiXtart handles API calls like Visual Basic and C++ I don't think there is any other way.



LonkeroAdministrator
(KiX Master Guru)
2008-09-10 04:37 PM
Re: ModifyStartMenu()

this UDF does not comply to the rules of the forum.
either fix it or it shall be moved elsewhere.


NTDOCAdministrator
(KiX Master)
2008-09-10 11:29 PM
Re: ModifyStartMenu()

Well it actually doesn't work so might as well move it or remove it.

LonkeroAdministrator
(KiX Master Guru)
2008-09-11 09:50 PM
Re: ModifyStartMenu()

lol.
are you saying, it never worked?


NTDOCAdministrator
(KiX Master)
2008-09-11 10:18 PM
Re: ModifyStartMenu()

It works for some things, but not everything. Also most Admins did not like the fact that it kills the Explorer shell and restarts it, but that often applets that were in the Startup Tray are no longer there.

So it is a bit Kludgey to use overall.


LonkeroAdministrator
(KiX Master Guru)
2008-09-12 09:15 AM
Re: ModifyStartMenu()

well, yeah, you could get it to work, if you rewrote the script but there are no parameters to be entered, which would allow any control over your script -> not a udf.
sadly, I stared your script for 5 mins and came to this conclusion and gave up. guess how the noobs feel? ;\)


Witto
(MM club member)
2008-09-12 03:15 PM
Re: ModifyStartMenu()

I looked at the options table and tried to find hard coded options in the script. But I presume they just are not there?

NTDOCAdministrator
(KiX Master)
2008-09-13 07:00 AM
Re: ModifyStartMenu()

DOH! Dang, I didn't even read this. I was thinking of my other UDF to kill explorer for a Desktop refresh, not this one.

This UDF does work, but it probably is not compliant. I'm actually working on something similar at work so I'll take a look at this and if possible will make it a proper UDF. But as a script it DOES WORK.


LonkeroAdministrator
(KiX Master Guru)
2008-09-13 11:14 PM
Re: ModifyStartMenu()

sorry, but like witto said...
I must insist that without major rewrite, one can't get it to do anything he/she wants.


NTDOCAdministrator
(KiX Master)
2008-09-15 12:19 AM
Re: ModifyStartMenu()

Whatever guy. I can make it do just as it says in the description. I agree the code is junky and old, but it does work.

Correct it is not in proper UDF format, but also there are so many options that it would be difficult to make it a "proper" UDF so aside from the code being here it probably won't be a UDF.