Batch Script – How to Check if the Current User is a Member of a Group

Here is a batch script, using only DOS commands, to check if the current user is a member of a specific group. The way it is currently written, you can call a batch file containing this code using the CALL command and pass the short NetBIOS domain name (or possibly the computer name if it is a local account) and the group name to search for as arguments, and it will return a “1” if the user is a member of the specified group and “0” if they are not. Just be sure to put quotes around any group name that contains any spaces. Continue reading “Batch Script – How to Check if the Current User is a Member of a Group”

Batch Script – Sending Items to the Recycle Bin Without Calling Any Third-Party Applications

While writing another larger script, I wanted the ability to send folders or files to the Recycle Bin, which I found out you can’t do natively via the command line without using some third-party apps or PowerShell.

I also found that when looping through a list of files in a batch script, it makes it really difficult to delete folders versus files because you have to either use the “del” command for files or the “rmdir” command for folders. With no simple way to differentiate between the two without a bunch of extra code, I kept looking for an alternative solution.
Continue reading “Batch Script – Sending Items to the Recycle Bin Without Calling Any Third-Party Applications”

Batch Script – Zip/Compress Files Without Calling Any Third-Party Applications

While writing another batch script the last several days, I found out that you cannot zip or compress files or folders natively from the command line without having additional third-party software or PowerShell. After a while of scouring the forums, I came up with this pure batch solution that uses VB script.

Basically, from this chunk of code in a single batch file, we can both generate the VB script, zip up whatever files we want, and then just delete the VB script when we’re done. Within the batch file, we can just call on the VB script using “CScript” and it works pretty much like any other function in any other programming language.
Continue reading “Batch Script – Zip/Compress Files Without Calling Any Third-Party Applications”