Scripting Blog [archived]

Formerly known as the "Hey, Scripting Guy!" blog

How Can I Extract Information Located Between Two Known Values in a Text File?

(image) Hey, Scripting Guy! In a text file, how can I extract the information that appears between the string HOSTNAME= and a blank space?-- B(image) (image) (image) Hey, B. You’ll have to pardon us if we seem a little sluggish today; we’re still recovering from all the fun and excitement of Windows PowerShell Week. What if you missed ...

How Can I Clear the Contents of Any File Dropped on My Script Icon?

(image) Hey, Scripting Guy! How can I write a script that will clear the contents of any file that I drag and drop on the script icon?-- SN(image) (image) (image) Hey, SN. Say, you didn’t by any chance misplace a few hundred thousand insects did you? OK; just thought we’d ask. This past weekend the Scripting Guy who writes this column ...

How Can I Remove Double Double Quotes From a Text File?

(image) Hey, Scripting Guy! I have a comma-separated values file that has data similar to this: data1",""data2"","data3",""data4"". As you can see, some of the items are enclosed by two sets of double quote marks (like ""data2""). How can I remove one of those sets of double quote marks, leaving the item looking like this: “data2”?-- RH(...

How Can I Get a Script to Delete Itself?

(image) Hey, Scripting Guy! I have a script for installing a printer that I give to my end users. When the script finishes, I’d like it to be able to delete itself. How can I get a script to delete itself?-- EA(image) (image) (image) Hey, EA. You know, that’s an interesting idea: disposable scripts, just like disposable razors or ...