Skip to content

Instantly share code, notes, and snippets.

@john-clark
Last active December 15, 2015 09:39
Show Gist options
  • Save john-clark/5240275 to your computer and use it in GitHub Desktop.
Save john-clark/5240275 to your computer and use it in GitHub Desktop.
Windows 8 Startmenu
Several scripts for Windows 8 (not 8.1)
Gives a start menu button with shutdown and several other fixes.
//created by win8fix.vbs
(new ActiveXObject("Shell.Application")).ShutdownWindows()
'created by win8fix.vbs
Option Explicit
Dim objShell, shell
set shell=createobject("wscript.shell")
shell.sendkeys "^{Esc}"
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' win8fix.vbs - Make 8 Great '
'---------------------------------------------------------'
' VBScript to fix the ease of use '
' Create start screen link and shutdown menu buttons '
' by John Clark '
' '
'---------------------------------------------------------'
'NOTICE: NO ERROR CHECKING - USE AT OWN RISK - MAY DO HARM'
'---------------------------------------------------------'
' '
' Version .03 - November 2012 '
' '
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Option Explicit
dim strPath, WshShell, objShell, objFSO
set WshShell = CreateObject("WScript.Shell")
Set objShell = CreateObject("Shell.Application")
Set objFSO = CreateObject("Scripting.FileSystemObject")
dim objFolder, objFolderItem ,objFiles, objFile, colVerbs, objVerb, getname, path, arrFiles, i
call createmyscripts
'call removetaskbaricons
'call createDesktopIcons
call createStartScreenIcons
call createTaskbarIcons
'call putbacktaskbaricons
'------------------------------------------------------------------------------------------------------'
' Desktop Shortcuts '
'------------------------------------------------------------------------------------------------------'
sub createDesktopIcons
strPath = WshShell.SpecialFolders("AllUsersDesktop")
call Create_Shortcut(Array(strPath, "Start.lnk", _
"%windir%\explorer.exe","C:\start.vbs", 1, _
"%windir%\system32\SHELL32.dll",130, _
"%systemroot%\System32\", "Start Menu", "", _
"no" _
) )
call Create_Shortcut(Array(strPath, "Stop.lnk", _
"%windir%\explorer.exe", "C:\shutdown.js", 1, _
"%windir%\system32\SHELL32.dll", 44, _
"%systemroot%\System32\", "Shutdown Menu", "", _
"no" _
) )
call Create_Shortcut(Array(strPath, "My Computer.lnk", _
"%windir%\explorer.exe", "shell:MyComputerFolder", 1, _
"%windir%\system32\SHELL32.dll", 15, _
"%systemroot%\System32\", "My Computer", "", _
"no" _
) )
call Create_Shortcut(Array(strPath, "Control Panel.lnk", _
"%windir%\explorer.exe", "shell:ControlPanelFolder", 1, _
"%windir%\system32\SHELL32.dll", 35, _
"%systemroot%\System32\", "Control Panel", "", _
"no" _
) )
end sub
'------------------------------------------------------------------------------------------------------'
' Start Screen Shortcuts '
'------------------------------------------------------------------------------------------------------'
sub createStartScreenIcons
strPath = WshShell.SpecialFolders("AllUsersStartmenu")
call Create_Shortcut(Array(strPath, "Shutdown.lnk", _
"%systemroot%\System32\shutdown.exe","-s -t 0", 1, _
"%systemroot%\System32\shell32.dll",27, _
"%systemroot%\System32\", "Shutdown Computer (Power Off)", "", _
"Pin to Start" _
) )
call Create_Shortcut(Array(strPath, "Log Off.lnk", _
"%systemroot%\System32\shutdown.exe","-l", 1, _
"%systemroot%\System32\shell32.dll",44, _
"%systemroot%\System32\", "Log Off (Switch User)", "", _
"Pin to Start" _
) )
call Create_Shortcut(Array(strPath, "Restart.lnk", _
"%systemroot%\System32\shutdown.exe","-r -t 0", 1, _
"%systemroot%\System32\shell32.dll",176, _
"%systemroot%\System32\", "Restart Computer (Reboot)", "", _
"Pin to Start" _
) )
call Create_Shortcut(Array(strPath, "Control Panel.lnk", _
"%windir%\explorer.exe", "shell:ControlPanelFolder", 1, _
"%windir%\system32\SHELL32.dll", 35, _
"%systemroot%\System32\", "Control Panel", "", _
"Pin to Start" _
) )
end sub
'------------------------------------------------------------------------------------------------------'
' Pin to Users Taskbar '
'------------------------------------------------------------------------------------------------------'
sub createTaskbarIcons
strPath = WshShell.ExpandEnvironmentStrings("%APPDATA%\Microsoft\Internet Explorer\Quick Launch")
call Create_Shortcut(Array(strPath, "Start.lnk", _
"%windir%\explorer.exe","C:\start.vbs", 1, _
"%windir%\system32\SHELL32.dll",130, _
"%systemroot%\System32\", "Start Menu", "", _
"Pin to Taskbar" _
) )
call Create_Shortcut(Array(strPath, "Stop.lnk", _
"%windir%\explorer.exe", "C:\shutdown.js", 1, _
"%windir%\system32\SHELL32.dll", 44, _
"%systemroot%\System32\","Shutdown Menu", "", _
"Pin to Taskbar" _
) )
call Create_Shortcut(Array(strPath, "My Computer.lnk", _
"%windir%\explorer.exe", "shell:MyComputerFolder", 1, _
"%windir%\system32\SHELL32.dll", 15, _
"%systemroot%\System32\","My Computer", "", _
"Pin to Taskbar" _
) )
call Create_Shortcut(Array(strPath, "Control Panel.lnk", _
"%windir%\explorer.exe", "shell:ControlPanelFolder", 1, _
"%windir%\system32\SHELL32.dll", 35, _
"%systemroot%\System32\", "Control Panel", "", _
"Pin to Taskbar" _
) )
end sub
'------------------------------------------------------------------------------------------------------'
' Create links 4 me '
'------------------------------------------------------------------------------------------------------'
Sub Create_ShortCut(argArray)
Dim objShortcutLnk, sShortCutPath, sShortCutName, sTargetPath, sArguments, iWinStyle, sDescription, sWorkPath, iIconNum, sIconPath, sHotkey, sPinned
sShortCutPath = argArray(0)
sShortCutName = argArray(1)
sTargetPath = argArray(2)
sArguments = argArray(3)
iWinStyle = argArray(4)
sIconPath = argArray(5)
iIconNum = argArray(6)
sWorkPath = argArray(7)
sDescription = argArray(8)
sHotkey = argArray(9)
sPinned = argArray(10)
Set objShortcutLnk = WshShell.CreateShortcut(sShortCutPath & "\" & sShortCutName)
If NOT objFSO.FileExists(objShortcutLnk) then
With objShortcutLnk
.TargetPath = WSHShell.ExpandEnvironmentStrings(sTargetPath)
.Arguments = sArguments
.WindowStyle = CStr(iWinStyle)
.Hotkey = sHotkey
.IconLocation = sIconPath & "," & CStr(iIconNum)
.Description = sDescription
.WorkingDirectory = WSHShell.ExpandEnvironmentStrings(sWorkPath)
.Save
End With
End If
if NOT sPinned = "no" then
Set objFolder = objShell.Namespace(sShortCutPath)
Set objFolderItem = objFolder.ParseName(sShortCutName)
Set colVerbs = objFolderItem.Verbs
For Each objVerb in colVerbs
If Replace(objVerb.name, "&", "") = sPinned Then objVerb.DoIt
Next
end if
End Sub
'------------------------------------------------------------------------------------------------------'
' Create some files '
'------------------------------------------------------------------------------------------------------'
sub createmyscripts
'for the shutdown menu
If NOT objFSO.FileExists("c:\shutdown.js") then
Set objFile = objFSO.CreateTextFile("c:\shutdown.js", True)
path = objFSO.GetAbsolutePathName("c:\shutdown.js")
getname = objFSO.GetFileName(path)
objFile.WriteLine("(new ActiveXObject(""Shell.Application"")).ShutdownWindows()")
objFile.Close
End If
'for the start menu
If NOT objFSO.FileExists("c:\start.vbs") then
Set objFile = objFSO.CreateTextFile("c:\start.vbs", True)
path = objFSO.GetAbsolutePathName("c:\start.vbs")
getname = objFSO.GetFileName(path)
objFile.WriteLine("Option Explicit")
objFile.WriteLine("Dim objShell, shell")
objFile.WriteLine("set shell=createobject(""wscript.shell"")")
objFile.WriteLine("shell.sendkeys ""^{Esc}""")
objFile.Close
End If
end sub
'------------------------------------------------------------------------------------------------------'
' save some existing taskbar icons '
'------------------------------------------------------------------------------------------------------'
sub removetaskbaricons
strPath = WshShell.ExpandEnvironmentStrings("%APPDATA%\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar\")
Set objFolder = objShell.Namespace(strPath)
Set objFiles = objFolder.Items
i = 0
redim arrFiles(i)
For Each objFile In objFiles
arrFiles(i) = ObjFile.Name
objFile.InvokeVerb("Unpin from Taskbar")
msgbox objfile
i = i + 1
redim preserve arrFiles(i)
Next
end sub
sub putbacktaskbaricons
strPath = WshShell.ExpandEnvironmentStrings("%APPDATA%\Microsoft\Internet Explorer\Quick Launch\")
Set objFolder = objShell.Namespace(strPath)
For i = 0 To UBound(arrFiles)
ObjFile.Name = arrFiles(i)
Set colVerbs = objFile.Verbs
For Each objVerb in colVerbs
If Replace(objVerb.name, "&", "") = "Pin to Taskbar" Then objVerb.DoIt
Next
Next
end sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment