I'm looking to display the %ComputerName% in a new toolbar, NOT the Taskbar from a VBScript for win10

John Franklin 66 Reputation points
2021-02-16T01:35:32.41+00:00

I'm looking to display the %ComputerName% in a new toolbar, NOT the Taskbar from a VBScript
This is what I've done so far..

Set FSO = CreateObject("Scripting.FileSystemObject")
Set wshShell = CreateObject( "WScript.Shell" )
strtemplocation = wshShell.ExpandEnvironmentStrings( "%TEMP%" )
strComputerName = wshShell.ExpandEnvironmentStrings( "%COMPUTERNAME%" )
' Write To A File
Set File = FSO.CreateTextFile(strtemplocation & "\computername.reg",True)
File.Write "Windows Registry Editor Version 5.00 " & Chr(13)+Chr(10)
File.Write " "& Chr(13)+Chr(10)
File.Write "[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CLSID{20D04FE0-3AEA-1069-A2D8-08002B30309D}]" & Chr(13)+Chr(10)
File.Write "@=" & chr(34)+strComputerName & chr(34)+Chr(13)+Chr(10)
File.Write Chr(13)+Chr(10)
File.Write "[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CLSID{20D04FE0-3AEA-1069-A2D8-08002B30309D}\DefaultIcon] " & Chr(13)+Chr(10)
file.Write"@=" & "C:\Windows\System32\imageres.dll,-109" & Chr(13)+Chr(10)
File.Write Chr(13)+Chr(10)
File.Close
Set objShell = CreateObject("Wscript.Shell")
strPath = Wscript.ScriptFullName
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile(strPath)
strFolder = objFSO.GetParentFolderName(objFile)
strPath = "regedit /s "&strtemplocation & "\computername.reg"
objShell.Run strPath

Dim WshShell
Dim strDesktopPath, strAllUsers, strCurrentUser, QuickLaunch, strIconPath
strDesktopPath = WshShell.ExpandEnvironmentStrings("%UserProfile%") & "\Desktop\"
strAllUsers = WshShell.ExpandEnvironmentStrings("%UserProfile%")
striconpath="\WINDOWS\system32\shell32.dll,15"
strURL = ""
Set objShortcutUrl = WshShell.CreateShortcut(strDesktopPath&strcomputername&".lnk")
objShortcutUrl.TargetPath = strURL
objShortcutUrl.IconLocation = strIconPath
objShortcutUrl.Save
'Create a Start menu option
strstartlocation = wshShell.ExpandEnvironmentStrings("%AppData%"&"\microsoft\windows\start menu\programs\System Tools\")
Set objShortcutUrl = WshShell.CreateShortcut(strstartlocation&strcomputername&".lnk")
objShortcutUrl.TargetPath = strURL
objShortcutUrl.IconLocation = strIconPath
objShortcutUrl.Save

'Create New Toobar
....................

Windows 10
Windows 10
A Microsoft operating system that runs on personal computers and tablets.
11,829 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Carl Fan 6,861 Reputation points
    2021-02-17T10:08:16.433+00:00

    Hi,
    According to your description, you want to right-click on Taskbar -> Go to Toolbars -> Choose New Toolbar, type in \%computername%, and Click Select Folder. Done.
    But if you want to use VBS to add new Items in Toolbar, to help you better, I suggest you post the issue on MSDN forum as they will be more professional on your code issue:
    https://social.technet.microsoft.com/Forums/scriptcenter/en-US/home?forum=ITCG
    Hope this helps and please help to accept as Answer if the response is useful.
    Best Regards,
    Carl

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.