Posts

Showing posts with the label Batch file

Subsystem for Unix-based Applications and Windows Batch scripts

Image
Image via Wikipedia Some time ago, I installed the SUA package with the thought I might use it for scripting and other tasks that I find easier to accomplish using GNU -like tools rather than Windows . Recently I needed to run a batch script that programatically checks for the evidence of some data files and injects them into MS Sql via DTS . This script worked fine on another server for years with a few tweaks now and then, and suddenly during my tests on this machine, it was failing. What I found was that my script was using the Windows FIND command, which is also installed by SUA. When I used FIND in my script, it was using the SUA flavor, and not the Windows version. I checked my PATH environment and saw that SUA's path was listed first, then %SystemRoot% , and %SystemRoot%\System32 where Windows FIND is installed. If I were a betting man, I'd have to say that since the SUA tools are listed before Windows, they get processed first. I've not tested this, but really...

Programmatically Change Printer Settings

Image
Image via Wikipedia I recently had the need to provide printer admin access on an ERP server to ordinary users. Nothing makes me shudder more than elevating a users access on a machine that holds your entire business operation on it's drives... I was able to come up with a solution using CPAU.exe which I've written about here . The scenario: An active label printer and a backup. When one goes down, the other needs to be put into service, but it needs to have the same name as the active one did. The users then also need to be able to "flip a switch" to put the active one back into service. First, I needed the guts of the switching script, which makes use of Microsoft 's prncnfg.vbs script, stored on all Windows boxes in the %windir%\ system32 directory (Called ChangePrinter.cmd) : @ECHO OFF @SET _ONE=ACTIVEPROD @SET _ONE_DOWN=ACTIVEPROD_146 @SET _TWO=BACKUPPROD @SET _HOST=BAPFSVR03 :: PRINTERS RECEIVE ADDRESSES VIA DHCP :: WHEN NO ERROR CONDITIONS E...

Running Logon Scripts with CPAU

Image
I like scripting . It helps me manage my client PC 's, perform redundant tasks, push out software updates, among other things. Most of the users on my network do not have privileges to install software, so this affects how some of my scripts function . I discovered that setting GPO to install applications with elevated privileges doesn't mean that the logon scripts also get processed the same way. This annoyed me, and I quickly found a solution. Introduce CPAU, from http://www.joeware.net/ . A neat little utility that takes the place of RUNAS, and very easy to use. I use it to launch my domain logon script, as it copies a HOST file , and other batch files run locally by the scheduler service, which are not allowed write by ordinary users. The following line encodes a file that will run logon.cmd using the credentials provided it. \\mydc\netlogon\cpau.exe -u mydomain\UserWithPermissions -p UserWithPermissionsPassword -ex \\mydc\netlogon\logon.cmd -file \\mydc\netlogon...