Should PS be able to run a VBscript this simply?

rated by 0 users
This post has 5 Replies | 0 Followers

Top 50 Contributor
Posts 78
Top Contributor
Archdeacon Posted: 12-05-2011 2:23 AM

ParadiseHow do I prevent PowerShell from running a named vbs Script? For example, I have a script
called 'Default.vbs', admittedly in the current $pwd directory, so that whenever I type 'default' in the PS console that script runs. Is there a way to stop this, as a simple 'typo' can act as a trigger?

Top 10 Contributor
Posts 634
Microsoft MVP
Top Contributor

PS can only launch files this simple when they are placed in one of the folders listed in $env:path. In all other places, a relative or absolute path name is required, i.e.

.\default.vbs

Top 50 Contributor
Posts 78
Top Contributor

ParadiseI see, but this runs by just typing 'default'  (without the quotes). I have a bunch of VBS scripts with PS accessible names, like format, args, param (all .vbs) so these will be triggered if I do not move them. Seems very risky to me! Thanks, anyway.

Top 25 Contributor
Posts 296
Microsoft MVP
Top Contributor

If you don't need VBScript you could disable the file association.  Also if you can run them by just using the script name it suggests that

cscript //H:CScript

has been run to make the command line the default

if you run

cscript //H:WScript

the defaults are reset which means you will use the graphical interface which will slow things down

best thing is to get theose scripts off the execution path

 

Top 10 Contributor
Posts 634
Microsoft MVP
Top Contributor

If you do not move your VBScripts, and if they have colliding names, then the same problem exists in a regular cmd session as well. I would move the VBScripts to some private folder.

Top 50 Contributor
Posts 78
Top Contributor

ParadiseThe problem has been solved by removing the .VBS tag from the $env:PathExt collection.

Page 1 of 1 (6 items) | RSS
Copyright 2012 PowerShell.com. All rights reserved.