Posts Tagged ‘ windows

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.

Command line scp from linux(+BSD) to windows.

i traveling and wanted to copy over my logs to find out what was happening on my server. didn’t want to install a client like filezilla or another GUI. Using the command line SCP utility, you can grab remote files securely over SSH. You can grab the executable from http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html (pscp.exe is what you want) then, in the command line on the windows client machine, type something like this:

pscp -r -P 22 jimmy@johnscomputer.com:/home/jimmy/stuff "c:\documents and settings\jimmy\Desktop"

The “-r” makes it grab the whole folder, and everything under. the “-P” specifies a port (mostly useful if you aren’t using 22. make sure it is capital).

Conference rooms with outlook and exchange 2007

Exchange Server 2007 allows administrators to create objects such as Mailbox, Contacts, Mail User, and Distribution Groups. Here are the steps needed to create a room mailbox object:

  1. Open the Exchange Management Console.
  2. Expand Recipient Configuration.
  3. Click on Mailbox.
  4. In the Mailbox pane, click on New Mailbox…
  5. For our purposes, we will pick “room mailbox” This is a mailbox to be assigned specifically to Meeting Rooms. Its associated user account will be disabled in Active Directory.
  6. In the User Type window, we can choose either to create a new user or to assign an existent user to the new resource mailbox. If we choose to assign it to an existent user, we will have to check if the account does not already have a mailbox associated to it. Click Next to continue.
  7. In the User Information window, we should fill out the user’s personal information and select the Organization Unit where it will be created. After that click on Next
  8. On the Mailbox Settings page, we can define the mailbox information such as Alias, Mailbox Server, and Mailbox Store where the new resource mailbox will be located. The policies for Mailbox and ActiveSync can also be defined in this step. We can choose which fields we are going to fill out and then click Next to continue.
  9. In the New Mailbox window, we will get a summary of all the information that we have selected in the previous steps. These parameters will be used by the cmdlet New-Mailbox for the creation of this resource mailbox object. To create the resource mailbox, click on New.
  10. In the Completion window, we will see the cmdlet New-mailbox and the parameters that we used in the creation process of this new resource mailbox.
  11. Grant yourself and users who will manage the mailbox “full access”. Right-click on the mailbox you just created and select manage full access permission.
  12. Sign into OWA.
  13. Click the dropdown next to your username on the upper-right corner of the screen and open up the room mailbox you just created.
  14. go to Options, then Resource settings
  15. go through these.
  16. Add the room mailbox to outlook.
  17. go to the calendar, right-click on the room’s calendar, go to properties.
  18. Under the permissions tab, set the default permission to “reviewer”. This will let everyone see what is going on in the room when they are scheduling

props to: http://www.msexchange.org/articles_tutorials/exchange-server-2007/management-administration/managing-resource-mailboxes-exchange-server-2007-part1.html

Windows XP’s /etc/hosts file

To my surprise, XP has an equivalent to unix’ “/etc/hosts” file. you can find it here:
c:\WINDOWS\system32\drivers\etc\hosts’

 

Switch to our mobile site