Prev: HTA VBscript MapIP Printing
Next: Space in HardDisk
From: JeffH on 23 Dec 2009 14:16 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
From: Pegasus [MVP] on 23 Dec 2009 14:43 "JeffH" <JeffH(a)discussions.microsoft.com> said this in news item news:DEA38ABB-28AA-481A-8883-5F2E0D7B1ED7(a)microsoft.com... > 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 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?
From: JeffH on 23 Dec 2009 15:51 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: > > > "JeffH" <JeffH(a)discussions.microsoft.com> said this in news item > news:DEA38ABB-28AA-481A-8883-5F2E0D7B1ED7(a)microsoft.com... > > 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 > > 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? > > . >
From: Pegasus [MVP] on 23 Dec 2009 16:23 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" <JeffH(a)discussions.microsoft.com> said this in news item news:E84472AC-9D88-4AFF-88CF-88E6A6AB0474(a)microsoft.com... > 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: > >> >> >> "JeffH" <JeffH(a)discussions.microsoft.com> said this in news item >> news:DEA38ABB-28AA-481A-8883-5F2E0D7B1ED7(a)microsoft.com... >> > 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 >> >> 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? >> >> . >>
From: JeffH on 23 Dec 2009 17:43
Pegasus, Thanks for your help. You solved my problem. Sincerely, JeffH "Pegasus [MVP]" wrote: > 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" <JeffH(a)discussions.microsoft.com> said this in news item > news:E84472AC-9D88-4AFF-88CF-88E6A6AB0474(a)microsoft.com... > > 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: > > > >> > >> > >> "JeffH" <JeffH(a)discussions.microsoft.com> said this in news item > >> news:DEA38ABB-28AA-481A-8883-5F2E0D7B1ED7(a)microsoft.com... > >> > 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 > >> > >> 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? > >> > >> . > >> > . > |