'================================================================== '* デスクトップとクイック起動に、シャットダウン・ログオフ・ロック のショートカットを作成しますYO! 'http://palm84.hatenablog.com/entry/20150508/1431028265 'http://d.hatena.ne.jp/palm84/20150823/1440328044 'http://d.hatena.ne.jp/palm84/20121028/1351419637 'http://www10.plala.or.jp/palm84/wsh.html 'http://www10.plala.or.jp/palm84/archives/wsh/Win8_CreateShutdownIcon.vbs.txt 'https://eu7w9wsmf6a74xyjdfzl3q-on.drv.tw/archives/wsh/Win8_CreateShutdownIcon.vbs.txt '================================================================== 'Shell オブジェクトを作成 Set objShell = WScript.CreateObject("WScript.Shell") 'FileSystemObject オブジェクトを作成 Set objFSO = WScript.CreateObject("Scripting.FileSystemObject") Const ForReading = 1, ForWriting = 2, ForAppending = 8 MyKakunin '*** 環境変数とか取得 *** Desktop = objShell.SpecialFolders("Desktop") QuickLaunch = objShell.ExpandEnvironmentStrings("%APPDATA%\Microsoft\Internet Explorer\Quick Launch") '*** OSバージョン取得 *** 'MyOperatingSystem Dim OSVersion OSVersion= myOS() 'WScript.Echo OSVersion '*** シャットダウン *** Title = "シャットダウン" strFile = QuickLaunch & "\Windows_Shutdown_dialog.vbs" strWorkingDirectory = "" strIcon = "%SystemRoot%\system32\SHELL32.dll, 215" If objFSO.FileExists(strFile) Then MySC Else Set objTxt = objFSO.OpenTextFile(strFile, ForWriting, true, -2) objTxt.WriteLine "Set objShellAp = Wscript.CreateObject(""Shell.Application"")" objTxt.WriteLine "objShellAp.ShutdownWindows()" objTxt.WriteLine "Set objShellAp = Nothing" objTxt.Close Set objFile = objFSO.GetFile(strFile) objFile.Attributes = objFile.Attributes + 2 MySC End If '*** ログオフ *** Title = "ログオフ" strFile = QuickLaunch & "\Windows_Logoff.vbs" strWorkingDirectory = "" strIcon = "%SystemRoot%\system32\SHELL32.dll, 211" If objFSO.FileExists(strFile) Then MySC Else Set objTxt = objFSO.OpenTextFile(strFile, ForWriting, true, -2) objTxt.WriteLine "Set objShell = Wscript.CreateObject(""WScript.Shell"")" objTxt.WriteLine "Kakunin = MsgBox (""ログオフしますか? (´・ω・`)"", 49 ,""ログオフするクマー! ( -(ェ)- ) zzZZZ "") " objTxt.WriteLine "If Kakunin = 1 Then" objTxt.WriteLine vbtab & "objShell.Run ""C:\Windows\System32\shutdown.exe /l""" objTxt.WriteLine "End If" objTxt.WriteLine "Set objShell = Nothing" objTxt.Close Set objFile = objFSO.GetFile(strFile) objFile.Attributes = objFile.Attributes + 2 MySC End If '*** コンピューターをロック *** Title = "コンピューターをロック" strFile = QuickLaunch & "\Windows_Lock_station.vbs" strWorkingDirectory = "" strIcon = "%SystemRoot%\system32\SHELL32.dll, 47" If objFSO.FileExists(strFile) Then MySC Else Set objTxt = objFSO.OpenTextFile(strFile, ForWriting, true, -2) objTxt.WriteLine "Set objShell = Wscript.CreateObject(""WScript.Shell"")" objTxt.WriteLine "Kakunin = MsgBox (""コンピューターをロックしますか? (´・ω・`)"", 49 ,""ロックするクマー!( -(ェ)- )"") " objTxt.WriteLine "If Kakunin = 1 Then" objTxt.WriteLine vbtab & "objShell.Run ""C:\Windows\System32\rundll32.exe user32.dll,LockWorkStation""" objTxt.WriteLine "End If" objTxt.WriteLine "Set objShell = Nothing" objTxt.Close Set objFile = objFSO.GetFile(strFile) objFile.Attributes = objFile.Attributes + 2 MySC End If '*** 詳細ブートオプション *** Title = "詳細ブートオプション" strFile = QuickLaunch & "\Win8_Reboot_option.vbs" strWorkingDirectory = "" strIcon = "%SystemRoot%\system32\shell32.dll, 238" 'If OSVersion = "Windows 10" Then strIcon = "%SystemRoot%\system32\shell32.dll, 238" If OSVersion = "Windows 10" Or OSVersion = "Windows 8" Then If objFSO.FileExists(strFile) Then MySC Else Set objTxt = objFSO.OpenTextFile(strFile, ForWriting, true, -2) objTxt.WriteLine "Set objShell = Wscript.CreateObject(""WScript.Shell"")" objTxt.WriteLine "Kakunin = MsgBox (""シャットダウンして「詳細ブートオプション」表示しますか? (´・ω・`)"", 49 ,""シャットダウンして「詳細ブートオプション」表示するクマー! ( -(ェ)- ) "") " objTxt.WriteLine "If Kakunin = 1 Then" objTxt.WriteLine vbtab & "objShell.Run ""C:\Windows\System32\shutdown.exe /o /r /t 0""" objTxt.WriteLine "End If" objTxt.WriteLine "Set objShell = Nothing" objTxt.Close Set objFile = objFSO.GetFile(strFile) objFile.Attributes = objFile.Attributes + 2 MySC End If End If Set objTxt = Nothing Set objShortCut = Nothing Set objFile = Nothing Set objFSO = Nothing Set objShortcut = Nothing Set objShell = Nothing '********************************************************* '* Function myOS '********************************************************* Function myOS() Reg_ProductName = "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProductName" myOS = objShell.RegRead(Reg_ProductName) If InStr(myOS, "Windows 10") > 0 Then myOS = "Windows 10" ElseIf InStr(myOS, "Windows 8") > 0 Then myOS = "Windows 8" ElseIf InStr(myOS, "Windows 7") > 0 Then myOS = "Windows 7" End If 'WScript.Echo myOS End Function '********************************************************* '* Sub MyKakunin '********************************************************* Sub MyKakunin Kakunin = MsgBox ("シャットダウンアイコンを作りますのん? (´・ω・`)", 65 ,"シャットダウンアイコンを作るYO! (´・ω・`) ") If Kakunin = 2 Then WScript.Quit End If End Sub '********************************************************* '* Sub MySC '********************************************************* Sub MySC strShortCut = QuickLaunch & "\" & Title & ".lnk" ' ショートカットオブジェクトを作成 *** Set objShortCut = objShell.CreateShortcut(strShortCut) With objShortCut ' リンク先 .TargetPath = strFile ' 作業フォルダ .WorkingDirectory = strWorkingDirectory ' 引数 .Arguments = "" ' コメント .Description = "" ' アイコン .IconLocation = strIcon End With objShortCut.Save ' ショートカットを DeskTop へコピー objFSO.CopyFile strShortCut, DeskTop & "\" 'WScript.Echo strFileName & "にショートカットを作成しました。" MsgBox "デスクトップとクイック起動にショートカットを作成しました YO!" & vbcrlf & vbcrlf & Title,64 ,"(´・ω・`) クマー! " End Sub '********************************************************* '* Sub MyOperatingSystem '********************************************************* Sub MyOperatingSystem On Error Resume Next Dim strComputer, objWMIService, colItems, objItem strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem",,48) 'Const Reg_ProductName = "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProductName" For Each objItem in colItems strOSVersion = objItem.Version Next Set objWMIService = Nothing On Error GoTo 0 End Sub