Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VBS vs PowerShell: Which is lighter?

If I need a script that executes with minimum effort from the system, which would I choose?

By looking at processes at Task Manager:

Memory (Private Working Set)
wscript.exe 2,068K
powershell.exe 33,144K

Thanks.

like image 630
mcu Avatar asked Feb 18 '12 17:02

mcu


2 Answers

There is a conservation of work principal going on here. If the machine does less work, then you have to do more work. If the machine does more work, you have to do less work.

Our philosophy with PowerShell was that the most important resource was the Admin's time and attention so we spend machine resources to deliver the best possible experience. So if you are looking for the lightest possible footprint on the machine, you should code it in 'C'. C++ is heavier than that and VBS is even heavier, and C# is even heavier, and they are lighter than PowerShell. Of course each one also requires more effort to produce a solution than PowerShell.

So the end of the day, what you end up with is a continuum of choices and what you need to do is decide what is the right tool for the problem at hand. We understood that from the beginning so we designed PowerShell to provide a smooth glide path to C# => C++ => C. This allows you to start with PowerShell and if it is too heavy, you can transition to another language without having to start over from scratch like you do with PERL => C.

like image 200
Jeffrey Snover - MSFT Avatar answered Nov 15 '22 22:11

Jeffrey Snover - MSFT


This clearly depends on what you need the script to do. There are vast differences in the capabilities between PowerShell and vbscript. PowerShell can leverage most capabilities of the .NET framework where vbs cannot. So there are some many things that you simply won't even be able to do with VBS.

If the script needs to do something that both can accomplish, typically you can accomplish the same thing in PowerShell in far fewer lines of code which makes the script easier to maintain and distribute. Sometimes what takes 10-50 lines of VBS can be accomplished by typing in a single PowerShell line at the shell.

So why do you need lightweight? Does the fact VBS may take slightly relatively less memory out weigh the benefits of PowerShell I talked about above? PowerShell will make you more productive and allow you to accomplish more due to it's powerful capabilities and will take less of your time and effort to do it.

like image 44
Andy Arismendi Avatar answered Nov 15 '22 21:11

Andy Arismendi