VBS vs PowerShell: Which is lighter?

前端 未结 2 916
一向
一向 2021-02-15 16:59

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)

相关标签:
2条回答
  • 2021-02-15 17:09

    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.

    0 讨论(0)
  • 2021-02-15 17:28

    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.

    0 讨论(0)
提交回复
热议问题