If you need to use a file path or URL in a script, here are a few guidelines: It doesn't change often and it is very unlikely to change without a version change that you can check in your script. So, instead of hard-coding a file system path, the best way to find an installation directory is to use the same technique that Windows uses. That doesn't seem like a particularly risky thing, but paths change and, in this case, we changed a path to conform to an updated Windows standard. This issue arose in a SAPIEN forum post (thanks for posting!) in which someone hard-coded the path to program that a PowerShell Studio installer file (.msi) installs. New-Variable pi -Value ::Pi -Option Constant So, wherever you can, use variables and wildcards for variable values and use constants for the few things in life that don't change, e.g. Using constants or "hard-coding" variable values is prone to error and requires continual maintenance. One of the important best-practice rules in scripting (and programming) is to avoid using constant values for things that can vary.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |