m-jelinski
Goto Top

VBS Skript für Signaturverteilung zeigt Fehlermeldung wenn kein Word installiert ist

Hallo zusammen,

ich habe ein VBS Skript, welches eine HTML Signatur für unsere Benutzer erstellt und dafür Variablen aus dem Active Directory nutzt. Das Skript wird per GPO beim Systemstart ausgeführt und funktioniert auf den Rechner super, auf denen MS Office installiert ist. Auf den Rechnern, welche kein Office haben, bringt es allerdings eine hässliche Fehlermeldung, die der Benutzer weg klicken muss. Kann ich diese Meldung unterbinden?

Hier der Part, welcher die Fehlermeldung hervorruft:

if not DevMode then
        'Set the signature as default for new and reply  
	Set objWord = CreateObject("Word.Application")  
	Set objSignatureObjects = objWord.EmailOptions.EmailSignature
	objSignatureObjects.NewMessageSignature = sUserName
	objSignatureObjects.ReplyMessageSignature = sUserName
	objWord.Quit
End If

Vielen Dank im Voraus!

Content-Key: 940649186

Url: https://administrator.de/contentid/940649186

Printed on: April 24, 2024 at 08:04 o'clock

Member: MrCount
MrCount Jul 08, 2021 at 07:43:03 (UTC)
Goto Top
Servus,

wie wäre es mit einem

try
...
catch
...
?
Member: emeriks
emeriks Jul 08, 2021 updated at 07:48:00 (UTC)
Goto Top
Zitat von @MrCount:
try
> ...
> catch
> ...

VBscript kennt kein Try-Catch
Member: emeriks
Solution emeriks Jul 08, 2021 updated at 07:48:31 (UTC)
Goto Top
Hi,
@m-jelinski
In Zeile 1 ein
On Error Resume Next

E.
Member: MrCount
MrCount Jul 08, 2021 at 08:57:06 (UTC)
Goto Top
Zitat von @emeriks:

VBscript kennt kein Try-Catch

Oh, hatte VBA gelesen. Mein Fehler... ^^
Member: emeriks
emeriks Jul 08, 2021 at 09:07:23 (UTC)
Goto Top
Zitat von @MrCount:
Oh, hatte VBA gelesen. Mein Fehler... ^^
Auch VBA kann kein Try-Catch. face-wink
Member: MrCount
MrCount Jul 08, 2021 at 09:41:28 (UTC)
Goto Top
Ist schon Freitag? face-big-smile
VB.... ohne S und ohne A ^^

Das kommt dabei raus, wenn man dauernd zwischen VB, VBA, Powershell und evtl. noch C++ switchen muss face-confused
Member: em-pie
em-pie Jul 08, 2021 at 19:01:42 (UTC)
Goto Top
Moin,

Zitat von @emeriks:

Hi,
@m-jelinski
In Zeile 1 ein
> On Error Resume Next
> 

E.

Oder im Vorfeld einfach mit
 if not exists "c:\Programme\Office\blabliblubb" exit   
prüfen, ob eine bestimmte Office vorhanden ist

Alternativ, mit einer VBS-Funktion arbeiten:
' Enforce variable declaration  
Option Explicit 

' Declare objects  
Dim oShell
Dim sOSVersion
Dim lOfficeVersion

Set oShell = CreateObject("WScript.Shell")  

On Error Resume Next
' Read the registry for the operating system version  
sOSVersion = oShell.RegRead("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProductName")  
lOfficeVersion = GetOfficeVersionNumber() ' Read the office version from the function  
'MsgBox "sOSVersion = " & sOSVersion & vbCrLf & "lOfficeVersion = " & lOfficeVersion  

    Function GetOfficeVersionNumber()
        GetOfficeVersionNumber = ""  ' or you could use "Office not installed"  
        Dim sTempValue
        ' Read the Classes Root registry hive (it is a memory-only instance amalgamation of HKCU\Software\Classes and HKLM\Software\Classes registry keys) as it contains a source of information for the currently active Microsoft Office Excel application major version - it's quicker and easier to read the registry than the file version information after a location lookup). The trailing backslash on the line denotes that the @ or default registry key value is being queried.  
        sTempValue = oShell.RegRead("HKCR\Excel.Application\CurVer\")  

        ' Check the length of the value found and if greater than 2 digits then read the last two digits for the major Office version value  
        If Len(sTempValue) > 2 Then GetOfficeVersionNumber = Replace(Right(sTempValue, 2), ".", "")   
     ' GetOfficeVersionNumber  
    End Function   
Quelle: https://stackoverflow.com/questions/13693490/vbs-or-bat-determine-os-and ...

Gruß
em-pie
Member: m-jelinski
m-jelinski Jul 09, 2021 at 07:27:53 (UTC)
Goto Top
Hat funktioniert. Vielen Dank!
Member: m-jelinski
m-jelinski Jul 09, 2021 at 07:28:19 (UTC)
Goto Top
Danke face-smile