Tuesday, December 18, 2012

Convert Word Docs To Text and mswrd632-wpc error

I had a share folder in which users were continuously dropping MS Word Docs, a mix of .doc and .docx files.  I needed to find a way to automatically convert those docs to text (.txt) so that they could be imported into a specialized database.  I found the perfect solution at

http://blogs.technet.com/b/heyscriptingguy/archive/2008/11/12/how-can-i-convert-word-files-to-pdf-files.aspx .  

It was easy to configure a Powershell script that I added a loop to and did the job perfectly.  However; after running for a day I started to get errors and docs were not being converted.  When I would try to manually open one of the problem docs, specifically .doc extensions in Word I would get a mswrd632-wpc error and have to click through the errors a couple times before the doc would open up.  I was able to manually save the problem doc as a docx and then the script would process it.  After some research I found this link:

http://helpdeskgeek.com/office-tips/word-cannot-start-the-converter-mswrd632-wpc/

I chose to delete the registry key at

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Text Converters\Import\MSWord6.wpc    

and that fixed my issue.
 
According to the original link author the only issue this causes is that Word97 docs no longer open in Wordpad.


Powershell script as I modified it for my project:

#Powershell Convert DoC and DCOX to plain txt

#infinite loop for running conversion
while(1)
{
$wdFormatText = 2
$word = New-Object -ComObject word.application
$word.visible = $false
$folderpath = "c:\fso\*"
$fileTypes = "*.docx","*doc"
Get-ChildItem -path $folderpath -include $fileTypes |
foreach-object `
{
$path =  ($_.fullname).substring(0,($_.FullName).lastindexOf("."))
"Converting $path to pdf ..."
$doc = $word.documents.open($_.fullname)
$doc.saveas([ref] $path, [ref]$wdFormatText)
$doc.close()

Remove-Item $_
}
$word.Quit()

Move-Item $folderpath\*.txt d:\someFolder
start-sleep - seconds 600
}

Sunday, December 16, 2012

Extend a Virtual Box Virtual drive

I manage some laptops that run a small application in an Oracle VirtualBox (VB) Virtual Machine.  The VMs run Win 7 64bit and are built on a 60G fixed size vmdk drive.  Recently it became evident that 60G is not large enough to the do job anymore.  I had several  options for moving this VM to a larger drive.  I could build a new version of the VM from the ground up on a larger virtual drive.   The next option I could use would be to image the VM with Clonezilla, Acronis etc then lay that image down on a larger drive and then if necessary use gparted to grow the system into the larger virtual drive.  The last option was to use VB commands to grow the drive then use gparted to expand the OS to use the extra space. I chose the last option.  

First my virtual disk was a 60gig fixed vmdk which VB can not expand, the disk needs to be dynamic vdi.  Luckily VB has a way to deal with that situation using the “Virtual Media Manager”

In VB open the Virtual Media Manager from the File menu.  
Select the target disk from the list
Click the copy button on toolbar
Click Next (here you can select a different drive if necessary)
Select VDI> Next
Select Dynamically Allocated>Next
Change copy name if necessary and or browse to a different folder
Click the copy button

Depending on the source virtual drive size this can take a while.

Next grow the copied virtual drive to the desired size: For example grow mydrive.vdi to 90Gig

C:\Program Files\Oracle\VirtualBox\VBoxManage.exe  modifyhd --resize 90000 "C:\path\mydrive.vdi”

Next
Create a new vm in VB and select “use an existing drive” when creating the new system.  Browse to your newly expanded drive and finish the configuration.

If you boot the newly created vm at this point Windows will still show the original size of the virtual disk and if you use disk manager you will see the new space as unallocated.  You can use that unallocated space to make a new drive or you can use a tool such as GPARTED to grow the C:\ drive to use the space.

Thursday, December 6, 2012

Use RedHat Disk For Yum Repository

I wanted to use a REDHAT 6 install disk as a Yum Repository since I did not plan on registering the system I built for practice.   Specifically I wanted to install x windows and a desktop after building the server without them.


Mount the install dvd:
mkdir /mnt/rhel_disc  (use whatever you want but make sure it matches the config file below on the line named “baseurl”.)

mount /dev/cdrom /mnt/rhel_disc


Create the config file dvd.repo at /etc/yum.repos.d
and add these lines:

[base]
name=CDROM
baseurl=file:///mnt/rhel_disc/Server
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

Thats it, now yum away.