#201186 - 2010-12-17 10:23 AM
Re: Urgent request - key lookup
[Re: Richard H.]
|
sparkie
Getting the hang of it
Registered: 2010-09-14
Posts: 92
Loc: UK
|
Ok, I've managed to get Blat working when the XP domain user logs on, how do I define the message so we know which computer has sent the email?
|
Top
|
|
|
|
#201188 - 2010-12-17 12:08 PM
Re: Urgent request - key lookup
[Re: Mart]
|
sparkie
Getting the hang of it
Registered: 2010-09-14
Posts: 92
Loc: UK
|
Mart, I'm using your edited example with $body, but we have no idea which PC the email is coming from
$ReturnCode = KeyExist("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\Default Outlook Profile")
;$ReturnCode = KeyExist("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\Outlook")
If $ReturnCode
$Sender = "ICT@@blah.com"
;Set a recipient address.
$Recipients = "ICT@@blah.com"
;Set the subject.
$Subject = '"TEST - Outlook Profile details"'
;SMTP server to be used for sending the message.
$smtpserver = "IP Adresss"
;Create the body text.
$Body = '"My Outlook Profile is Outlook"'
;Send the message.
$Send = BlatMailerNoAttachment($Recipients, $Sender, $Subject, $Body, $smtpserver)
Function BlatMailerNoAttachment($Recipient, $Sender, $Subject, $Body, $smtpserver)
Dim $MailerLine
$MailerLine = '\\artic\Blat\blat.exe -' + ' -to ' + $recipient + ' -f ' + $sender + ' -subject ' + $subject + ' -body ' + $body + ' -server ' + $smtpserver + ' -q '
Shell $MailerLine
EndFunction
ELSE
?"do nothing"
ENDIF
Edited by Richard H. (2010-12-17 12:15 PM) Edit Reason: Added code tags
|
Top
|
|
|
|
#201190 - 2010-12-17 12:21 PM
Re: Urgent request - key lookup
[Re: Richard H.]
|
Richard H.
Administrator
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
In your sample script you may change the following variables accordingly:
$Sender = @USERID+"@@"+@WKSTA+".blah.com"
$Body = '"My Outlook Profile is Outlook, I am workstation '+@WKSTA+'"
|
Top
|
|
|
|
#201191 - 2010-12-17 12:23 PM
Re: Urgent request - key lookup
[Re: Richard H.]
|
BradV
Seasoned Scripter
Registered: 2006-08-16
Posts: 686
Loc: Maryland, USA
|
Following Glen's suggestion, here is some untested code:
Dim $Key, $ReturnCode, $Wks, $Val, $User, $File, $DataPath
;
$Key = "HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\Outlook"
;
$ReturnCode = KeyExist($Key)
If $ReturnCode
; The key does exist. Write the information to the central server.
$Wks = @WkSta
$val = ReadValue($Key,"")
$User = @USERID
$File = "%TEMP%" + "\" + $Wks + "-" + @TIME + ".ini"
$DataPath = "\\server\share\profile_folder"
;
$ReturnCode = WriteProfileString($File, $Wks, "Profile Key Exists", "True")
$ReturnCode = WriteProfileString($File, $Wks, "User", $User)
$ReturnCode = WriteProfileString($File, $Wks, "Workstation", $Wks)
$ReturnCode = WriteProfileString($File, $Wks, "Default Value", $Val)
;
Move $File $DataPath
EndIf
Then you just need to write a script on the central server to check the contents of the directory periodically. You may not even need blat.
|
Top
|
|
|
|
#201203 - 2010-12-17 04:18 PM
Re: Urgent request - key lookup
[Re: sparkie]
|
Richard H.
Administrator
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Is there a list of all the permitations of 'equal/not equal to' because I want it to email if the key does not equal 'Outlook'?
I think you mis-understand the registry keys.
Within "HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles" you can have many profilses, not just one. Most people will only have one on their work machine, but they may have more. To check what keys are present you have to enumerate them.
There is a value which defines which (if any) of the messaging profiles is the default.
The important thing to note is that the profile name is not fixed and is not significant - it could be "Outlook" or "Billy's mail" or just about anything.
If you want to check the default profile here is an example of how you might do it:
$sProfileKey="HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles"
$sDefaultProfileValue="DefaultProfile"
$sExpectedProfile="Default Outlook Profile"
$sProfile=ReadValue($sProfileKey,$sDefaultProfileValue)
If $sProfile=$sExpectedProfile
"Your default messaging profile matches the expected '"+$sExpectedProfile+"'"+@CRLF
Else
"Your default messaging profile is '"+$sProfile+"' which does not match the expected '"+$sExpectedProfile+"'"+@CRLF
EndIf
You will get better answers from us if you explain what you are checking for and why, otherwise we may send you off down an inappropriate route.
|
Top
|
|
|
|
#201205 - 2010-12-17 04:31 PM
Re: Urgent request - key lookup
[Re: Les]
|
sparkie
Getting the hang of it
Registered: 2010-09-14
Posts: 92
Loc: UK
|
Is there a list of all the permitations of 'equal/not equal to' because I want it to email if the key does not equal 'Outlook'? Huh? The function tests whether or not it "Exists". If it exists, it is "equal to", if it doesn't it is "not equal to". There is no in between. It is a true/false.
Sorted now, used this
If NOT $ReturnCode
If the key does not equal to the $ReturnCode I get the email, if it does we get nothing. Just as we wanted.
Thanks everyone for their help and have a Happy Christmas
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
1 registered
(Allen)
and 382 anonymous users online.
|
|
|