Archive for the ‘ windows ’ Category

Windows 32 (x86) or 64 (AMD64) detection in batch files

While there are a lot of ways to detect for a 64 bit version of windows. you can test for %programFiles(x86)%, but handling the output and writing the IF comparisons is messy.

In Batch files, you can easily check for architecture by using the “processor_architecture” variable. x86 versions of windows will have this set to “x86″, and x64 versions “x64″. Heres an easy example:

@echo off
IF %processor_architecture% == AMD64 echo This is a 64-bit version of windows
IF %processor_architecture% == x86 echo this is a 32-bit version of windows.
pause

Uninstall ALL Versions of WinZip Batch Script

I have been struggling with this for quite a while, and ran into a lot of issues with all of the different versions on our network. There are people with 100 line .vbs scripts to do this, and I think this is much simpler:

@echo off
REM
REM
REM    Detects winzip and silently uninstalls
REM    There is a un-stoppable pop-up window. so this will kill
REM    all instances of  IE after the UN-installation.
REM
REM
REM
taskkill /F /IM wzqkpick.exe
wmic product where "name like '%%winzip%%'" call Uninstall
REM
REM This section is for WinZip <12
REM
If Exist "%programfiles(x86)%\Winzip\winzip32.exe" GOTO 64
If Exist "%programfiles%\Winzip\winzip32.exe" "%programfiles%\WinZip\Winzip32.exe" /Uninstallx
taskkill /F /IM iexplore.exe
GOTO :END
:64
"%programfiles(x86)%\WinZip\Winzip32.exe" /Uninstallx
taskkill /F /IM iexplore.exe
:END

For getting rid of WinZip 12, the magic happens in the 'wmic' line. It searches all of the installed product's names for "winzip" and will uninstall anything it finds. This only works for products that use MSI's. If you ran this outside of a batch file, you will have to use a single % percentage sign instead of the %% double percentage sign... Windows scripting sucks, and that's just the way it is. Same thing that happens in "FOR" loops.

I never knew anything about the Windows management instrumentation control (wmic) until now, but I will be sure to exploit it's features.

Set Windows Environment variables through registry.

The system variables are in there, so you can change and add to them permanently.

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment

Remotely change power options in XP

First of all, get the pstools and set them up. then run

psexec \\[workstation name] powercfg /query
Field Description          Value
-----------------          -----
Name                       Home/Office Desk
Numerical ID               0
Turn off monitor (AC)      After 20 mins
Turn off monitor (DC)      After 5 mins
Turn off hard disks (AC)   After 60 mins
Turn off hard disks (DC)   After 10 mins
System standby (AC)        Never
System standby (DC)        After 5 mins
System hibernates (AC)     Never
System hibernates (DC)     After 20 mins
Processor Throttle (AC)    Not Supported
Processor Throttle (DC)    Not Supported

that will tell you what the current settings are. After that, you can set the power scheme by doing this:

psexec \\[workstation name] powercfg /setactive "[scheme name]"

It will exit with “error code 0″, but no worries. Just check your work using the query command above after your changes.

Logitech webcam drivers

Logitech drivers are packed in with an awful, bloated program. Just want the drivers and nothing else? I did this with a Quickcam 4000 Pro. The same basic steps may apply to other cams:

1. Download the Program from logitech.com
2. use 7-zip, winRAR, or some other decent compression program to extract the contents of the .exe to a folder on you computer.
3. Open up Device Manager. right-click on the unknown USB device, and select “Update Driver”.
4. Point it at the folders you extracted. it should be under a folder appropriately named “drivers”. mine was in “pro”.
5. happy happy. you web cam works without the extra bloat.

 

Switch to our mobile site