Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Trying to run a non-Win32 Application

8 views
Skip to first unread message

JeffH

unread,
Dec 23, 2009, 2:16:01 PM12/23/09
to
Hi,

I don't know if I am in the correct newsgroup. If I am not, please let me
know.

I have a dilemma that starts with MS Outlook. I am trying to install
updates onto the outlook Calendar without user intervention by using a
vbScript. The problem that is happening is that if a user clicks on a button
in Outlook called "Add Holidays ..." then a GUI titled 'Add holidays to
Calendar' is invoked. If I double click on a particular file in the program
directory, namely Outlook.hol, then the GUI titled 'Add holidays to Calendar'
is invoked. Another way of doing this is to navigate a DOS prompt to the
folder where Outlook.HOL is located, type in Outlook.HOL and hit enter, then
the GUI titled 'Add holidays to Calendar' is also invoked. I just can't get
the GUI to be invoked through vbscript. Is there a way around my dilemma or
is there a limitation in vbScript that I don't know about?

Thanks in advance,
JeffH

Pegasus [MVP]

unread,
Dec 23, 2009, 2:43:46 PM12/23/09
to

"JeffH" <Je...@discussions.microsoft.com> said this in news item
news:DEA38ABB-28AA-481A...@microsoft.com...

What is the association on your machines for .HOL files? Which .exe file?
Have you tried invoking the .exe file instead, with the .HOL file as a
parameter?

JeffH

unread,
Dec 23, 2009, 3:51:02 PM12/23/09
to
Hi,

The association on my machine is "C:\PROGRA~1\MICROS~2\Office10\OUTLOOK.EXE"
/hol "%1". When I try to pass this in as a parameter I receive an error "The
system cannot find the file specified". My code looks like this:

Const ForReading = 1
Const OverwriteExisting = TRUE

strComputer = "."

Set objWMIService=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &
_
strComputer & "\root\cimv2")
WScript.Echo "Starting"
Set objShell = WScript.CreateObject("Wscript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
strFile = "c:\Program Files\Microsoft Office\Office10\1033\Outlook.HOL"
strOldFile = "c:\Program Files\Microsoft Office\Office10\1033\Outlook.OLD"
If objFSO.FileExists ("C:\Program Files\Microsoft
Office\Office10\1033\Outlook.HOL") Then
objFSO.CopyFile "\\server\folder\Outlook.HOL", "c:\Outlook.HOL",
OverwriteExisting
WScript.Echo "Copied to C:"
objFSO.MoveFile strFile, strOldFile
objFSO.CopyFile "C:\Outlook.HOL", strFile, OverwriteExisting
WScript.Echo "Copied to the directory"
objShell.Run ("C:\PROGRAM FILES\MICROSOFT OFFICE\Office10\1033\OUTLOOK.EXE
/HOL (strFile)")
objShell.SendKeys "~"
wScript.Echo "Installed"
End If

AM I passing in the variable correctly?

Thanks,
JeffH

"Pegasus [MVP]" wrote:

> .
>

Pegasus [MVP]

unread,
Dec 23, 2009, 4:23:39 PM12/23/09
to
It's the old problem of missing out on some double quotes. If you replace
the line

objShell.Run ("C:\PROGRAM FILES\MICROSOFT OFFICE\Office10\1033\OUTLOOK.EXE
/HOL (strFile)")

with this line

wscript.echo "C:\PROGRAM FILES\MICROSOFT OFFICE\Office10\1033\OUTLOOK.EXE
/HOL (strFile)"

and run your script from the console then you will immediately see why the
Command Processor cannot possibly execute outlook.exe. You might try this:

DQ = """"
sOutlook = "C:\PROGRAM FILES\MICROSOFT OFFICE\Office10\1033\OUTLOOK.EXE"
objShell.Run DQ & sOutlook & DQ & " /HOL " & DQ & strFile & DQ

Note also that the SendKeys method is unreliable that can and will be
tripped up by numerous unanticipated events. It's best avoided altogether.

"JeffH" <Je...@discussions.microsoft.com> said this in news item

news:E84472AC-9D88-4AFF...@microsoft.com...

JeffH

unread,
Dec 23, 2009, 5:43:02 PM12/23/09
to
Pegasus,

Thanks for your help. You solved my problem.

Sincerely,
JeffH

"Pegasus [MVP]" wrote:

> .
>

Pegasus [MVP]

unread,
Dec 23, 2009, 5:51:22 PM12/23/09
to

"JeffH" <Je...@discussions.microsoft.com> said this in news item

news:8E0427E6-C325-4CBF...@microsoft.com...


> Pegasus,
>
> Thanks for your help. You solved my problem.
>
> Sincerely,
> JeffH
>

Thanks for the feedback.

0 new messages