Solved vbs replacement


rogerrabbit

Member
Member
Local time
2:54 AM
Posts
28
OS
Windows 11
Hi,

after a recent clean install, I rembered to have read somwhere that vbs is deprecated. But I have two vb scripts which I have saved to put them back in my installation, whenever I do a clean install. One is for my "show / hide hidden files" context menu entry, it's from Vishal Gupta: Add “Show / Hide Hidden Files” Option in Desktop and Explorer Context Menu in Windows. The other one is for a shortcut to safemode (I don't remember where i got it from).

The first vb script is combined with a modification of the registry. The above shown link (for the registry change) also shows a link to the corresponding vb script. But this second link does not work anymore. So I copy the complete vb script here:

---------------------------------------------------------------------------------------------------------

Hidden = "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Hidden"
SSHidden = "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ShowSuperHidden"
Set Command1 = WScript.CreateObject("WScript.Shell")
Check = Command1.RegRead(Hidden)
If Check = 2 Then
Command1.RegWrite Hidden, 1, "REG_DWORD"
Command1.RegWrite SSHidden, 1, "REG_DWORD"
Else
Command1.RegWrite Hidden, 2, "REG_DWORD"
Command1.RegWrite SSHidden, 0, "REG_DWORD"
End If
Command1.SendKeys "{F5}"

-----------------------------------------------------------------------------------------------------------

My intention was now to change the vb script to a php or ps1 script. As I have no clue about coding, I found an internet site which does the transformation automatically. I then renamed the vbs file to php/ps1 and modified the reference in the reg file accordingly.

But when I try out the context menu entry, I am getting an error saying that there is no "motor" on my system allowing to run the php or ps1 file. I suppose the motor is the "Wscript".exe to which the vbs file refers (and also the reg file).

Capture.webp

I know there are other solutions for the context menu entry to be found on the net, but they are less elegant: you get a short black screen when toggeling the show/hidden state and you need two context menu entries, one for showing the files another one for hiding the files. The solution from Vishal Gupta allow to toggle with one single rightclick menu entry.

So if someone could help me to obtain the right "motor" to get the php or ps1 file to run, I would be greatful.
 
Windows Build/Version
Windows 11 25H2 26200.8037

My Computer My Computer

At a glance

Windows 11Intel Core i3 12 100 12th generationKingston DDR4-3200 16 GBytesIntel UHD 730
OS
Windows 11
Computer type
PC/Desktop
Manufacturer/Model
Gigabyte H610M H V2 DDR4 (Rev. 1.0)
CPU
Intel Core i3 12 100 12th generation
Motherboard
American Megatrend F34
Memory
Kingston DDR4-3200 16 GBytes
Graphics Card(s)
Intel UHD 730
By "motor," they likely mean engine, as in a scripting engine. Windows Script Host does not run PowerShell scripts. You probably need to change the reg file so that it calls powershell.exe, not wscript or cscript. Can you post the contents of the reg file?
 

My Computer My Computer

At a glance

Windows 11 Pro 25H212th Gen Core i7-1260P64 GB Micron PC4-25600Intel Iris Xe Graphics
OS
Windows 11 Pro 25H2
Computer type
PC/Desktop
Manufacturer/Model
Intel NUC12WSHi7
CPU
12th Gen Core i7-1260P
Motherboard
NUC12WSBi7
Memory
64 GB Micron PC4-25600
Graphics Card(s)
Intel Iris Xe Graphics
Sound Card
on-board Realtek HD Audio
Monitor(s) Displays
Dell U3219Q
Screen Resolution
3840 x 2160
Hard Drives
Samsung SSD 990 PRO 1TB
Crucial MX500 2 TB
Antivirus
Microsoft Defender
Looks like a simple VBS to switch the "Show hidden & system files" options in Explorer. There's no script arguments, since it's designed to toggle between the two different modes.

Here's a cleaned up version in PowerShell.
Code:
$regPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"

if ((Get-ItemPropertyValue -Path $regPath -Name Hidden) -eq 2) {
    Set-ItemProperty -Path $regPath -Name Hidden -Value 1
    Set-ItemProperty -Path $regPath -Name ShowSuperHidden -Value 1
}
else {
    Set-ItemProperty -Path $regPath -Name Hidden -Value 2
    Set-ItemProperty -Path $regPath -Name ShowSuperHidden -Value 0
}

$wshell = New-Object -ComObject wscript.shell
$null = $wshell.AppActivate("Explorer")
Start-Sleep -Seconds 1
$wshell.SendKeys("{F5}")

For the context menu command:
Code:
powershell -ep bypass -F \path\to\saved\script.ps1
 

My Computer My Computer

At a glance

Windows 7
OS
Windows 7
Thank you to both of you. I'll try it out an report back.

(@pseymore: the content of the reg file is as follows:

------------------------------------------------------------------------------------------------------------
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\Background\shell\Show/Hide Hidden Files]
"HasLUAShield"=""

[HKEY_CLASSES_ROOT\Directory\Background\shell\Show/Hide Hidden Files\command]
@="WScript C:\\Windows\\Toggle_Show_Hidden_Files_On_Off.vbs"

[HKEY_CLASSES_ROOT\LibraryFolder\Background\shell\Show/Hide Hidden Files\command]
@="WScript C:\\Windows\\Toggle_Show_Hidden_Files_On_Off.vbs"
-------------------------------------------------------------------------------------------------------------
 

My Computer My Computer

At a glance

Windows 11Intel Core i3 12 100 12th generationKingston DDR4-3200 16 GBytesIntel UHD 730
OS
Windows 11
Computer type
PC/Desktop
Manufacturer/Model
Gigabyte H610M H V2 DDR4 (Rev. 1.0)
CPU
Intel Core i3 12 100 12th generation
Motherboard
American Megatrend F34
Memory
Kingston DDR4-3200 16 GBytes
Graphics Card(s)
Intel UHD 730
Since the PS command will be embedded inside a reg file:
Code:
[HKEY_CLASSES_ROOT\Directory\Background\shell\Show/Hide Hidden Files\command]
@="powershell -ep bypass -F C:\\path\\to\\script.ps1"

[HKEY_CLASSES_ROOT\LibraryFolder\Background\shell\Show/Hide Hidden Files\command]
@="powershell -ep bypass -F C:\\path\\to\\script.ps1"
 

My Computer My Computer

At a glance

Windows 7
OS
Windows 7
Thank you works fine :-):-)
 

My Computer My Computer

At a glance

Windows 11Intel Core i3 12 100 12th generationKingston DDR4-3200 16 GBytesIntel UHD 730
OS
Windows 11
Computer type
PC/Desktop
Manufacturer/Model
Gigabyte H610M H V2 DDR4 (Rev. 1.0)
CPU
Intel Core i3 12 100 12th generation
Motherboard
American Megatrend F34
Memory
Kingston DDR4-3200 16 GBytes
Graphics Card(s)
Intel UHD 730
Sorry for coming back to this, but something has changed in Windows (recent update ?).
When I now try to run the reg file proposed by @garlin in post n° 5 (which worked fine before) I am getting the following error (translated):

"Impossible to import ... [the reg file] ..: the specified file is not a registry script.
You can only import binary registry files from the registry editor".
See screenshot:

Capture.webp


Could you (all) possibly help out again ?

Thanks in advance
 

My Computer My Computer

At a glance

Windows 11Intel Core i3 12 100 12th generationKingston DDR4-3200 16 GBytesIntel UHD 730
OS
Windows 11
Computer type
PC/Desktop
Manufacturer/Model
Gigabyte H610M H V2 DDR4 (Rev. 1.0)
CPU
Intel Core i3 12 100 12th generation
Motherboard
American Megatrend F34
Memory
Kingston DDR4-3200 16 GBytes
Graphics Card(s)
Intel UHD 730
Make sure you have the 'Windows Registry Editor Version 5.00' at the top of the reg file. garlin's example doesn't include it.
 

My Computer My Computer

At a glance

Windows 11 Pro 25H212th Gen Core i7-1260P64 GB Micron PC4-25600Intel Iris Xe Graphics
OS
Windows 11 Pro 25H2
Computer type
PC/Desktop
Manufacturer/Model
Intel NUC12WSHi7
CPU
12th Gen Core i7-1260P
Motherboard
NUC12WSBi7
Memory
64 GB Micron PC4-25600
Graphics Card(s)
Intel Iris Xe Graphics
Sound Card
on-board Realtek HD Audio
Monitor(s) Displays
Dell U3219Q
Screen Resolution
3840 x 2160
Hard Drives
Samsung SSD 990 PRO 1TB
Crucial MX500 2 TB
Antivirus
Microsoft Defender
Thanks ! That did the trick. (y)
 

My Computer My Computer

At a glance

Windows 11Intel Core i3 12 100 12th generationKingston DDR4-3200 16 GBytesIntel UHD 730
OS
Windows 11
Computer type
PC/Desktop
Manufacturer/Model
Gigabyte H610M H V2 DDR4 (Rev. 1.0)
CPU
Intel Core i3 12 100 12th generation
Motherboard
American Megatrend F34
Memory
Kingston DDR4-3200 16 GBytes
Graphics Card(s)
Intel UHD 730

Latest Support Threads

Back
Top Bottom