- Batch Script – Get User’s SID One-Liner
- Batch Script – How to Check if the Current User is a Member of a Group
- Batch Script – Parse MS Exchange IIS Log File, Filter All External Requests, and Email It
- Batch Script – RDS Start Menu Application and Taskbar Shortcut Removal Tool
- Batch Script – Ribbon UI Customization: Take Ownership and Change Permissions of the CommandStore Subkeys in the Registry
- 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
- KB947222 – Addressing the User Profile Redirection Display Problem with a Different Approach
- Windows – How to Run Elevated Scripts as a Regular User with Task Scheduler -OR- How to Restart Services as a Standard User
Table of Contents - Batch Scripting
Most Popular - Batch Scripting
- Batch Script – RDS Start Menu Application and Taskbar Shortcut Removal Tool 916 views
- Windows – How to Run Elevated Scripts as a Regular User with Task Scheduler -OR- How to Restart Services as a Standard User 886 views
- Batch Script – Zip/Compress Files Without Calling Any Third-Party Applications 771 views
- Batch Script – Ribbon UI Customization: Take Ownership and Change Permissions of the CommandStore Subkeys in the Registry 631 views
- Batch Script – Get User’s SID One-Liner 431 views
- KB947222 – Addressing the User Profile Redirection Display Problem with a Different Approach 201 views
- Batch Script – Sending Items to the Recycle Bin Without Calling Any Third-Party Applications 140 views
- Batch Script – Parse MS Exchange IIS Log File, Filter All External Requests, and Email It 99 views
- Batch Script – How to Check if the Current User is a Member of a Group 86 views
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.
I needed a way to track which Exchange users were remotely retrieving their emails outside of the office on their phones and other email clients, so I pieced together this batch/pseudo VB script that can be ran from the Windows Task Scheduler at midnight. The only dependency/third party app required is the MS Log Parser executable. Also, for the SQL query to filter out the proper internal networks from the log file, you will have to edit the LOCALSUBNET and CHARLENGTH variables.
Windows – How to Run Elevated Scripts as a Regular User with Task Scheduler -OR- How to Restart Services as a Standard User
Here is a neat workaround you can use in Windows to run a batch script or any other command that would regularly require elevated administrator credentials. Using this method, you can essentially bypass UAC and allow a script to be ran as a standard user without them having to enter in an admin password. In theory, you could probably even use this same approach to install software as a regular user if you wanted to. For my example below, I was able to allow a standard user to kill processes and then restart the services.
The problem that I had to overcome was that one of my VPN users who used Shrewsoft VPN client would occasionally get disconnected and then never be able to fully connect again. Oddly enough, the client would show connected on the user’s end and immediately disconnect but it never made a connection on the server side. The problem was that the “iked” process would get hung up and then the VPN client would subsequently never fully connect all the way. View Post
Batch Script – Ribbon UI Customization: Take Ownership and Change Permissions of the CommandStore Subkeys in the Registry
This is just a follow up to my experiences customizing the Ribbon UI icons in Server 2012 and where the path has taken me thus far. After many hours of research and development and a lot of head scratching, I’ve written several posts on how to disable the different icons in the Ribbon UI which requires the adding or editing of keys in the CommandStore section of the registry for Windows Explorer. For more information on how to disable the icons, see this post.
My whole goal as of late was to be able to add these registry items to the RDS server’s GPO to be able to deploy these settings to all 7 of my RDS servers but then I found out you can’t take ownership of the CommandStore subkeys with the local “SYSTEM” account. Yet another deliberate Microsoft setback meant to discourage people from editing the Ribbon UI, oh well, fuck ’em. I’ve encountered so many problems with this RDS server project it is unreal and this was just icing on the proverbial cake. View Post
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.
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.
While researching a way to try and send files to a user’s Recycle Bin from a batch script, I came across this one liner either at StackExchange or SuperUser forums somewhere. FYI, there is no way natively to send something to the trash without using a VB script or some third party utility. Yes you can physically move the files into the C:\$Recycle.Bin\<UsersSID> folder, but the files will not show up in Explorer and won’t be removed when you empty the trash that way.