Page 2 of 2 <12
Topic Options
#201184 - 2010-12-16 08:10 PM Re: Urgent request - key lookup [Re: Glenn Barnas]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
Oh - and RESIST the temptation to
  • write directly to the server.. the monitor service can find and read your file before you've completely written it. Create it locally and then move it to the share.
  • Short-cut and try to write directly to a single central file. There's no file locking, so its possible for you to lose data this way.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#201185 - 2010-12-17 08:50 AM Re: Urgent request - key lookup [Re: Glenn Barnas]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
It depends on your need. In this case small INI files on a central server are fine, even a monolithic file is fine as long as the total user base and concurrent login count is small. If it doesn't matter so much whether you are alerted the first time someone logs in or the third time that they log in then it doesn't warrant significant additional coding complexity which has to be maintained. If you do need to know first time then validate by reading back and re-doing the WriteValue() in a simple loop. Definately use INI files though, flat text files are more of a problem and require more complex coding from the start.

Sometimes good enough is all that is needed to do the job.

Top
#201186 - 2010-12-17 10:23 AM Re: Urgent request - key lookup [Re: Richard H.]
sparkie Offline
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
#201187 - 2010-12-17 11:17 AM Re: Urgent request - key lookup [Re: sparkie]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
In my example above I use the $Body variable for the body text of the message. You can out your data in there.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#201188 - 2010-12-17 12:08 PM Re: Urgent request - key lookup [Re: Mart]
sparkie Offline
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

 Code:
$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
#201189 - 2010-12-17 12:14 PM Re: Urgent request - key lookup [Re: Mart]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
You can declare it in the body using the "From:" SMTP header, but also look at the BLAT "-i" and "-f" options which allow you to specify the sender, or use the more granular envelope options that are available.

From the BLAT documentation:
 Originally Posted By: BLAT documentation
Note that if the '-i' option is used, <sender> is included in 'Reply-to:'
and 'Sender:' fields in the header of the message.

Optionally, the following options can be used instead of the -f and -i
options:

-mailfrom <addr> The RFC 821 MAIL From: statement
-from <addr> The RFC 822 From: statement
-replyto <addr> The RFC 822 Reply-To: statement
-returnpath <addr> The RFC 822 Return-Path: statement
-sender <addr> The RFC 822 Sender: statement

For backward consistency, the -f and -i options have precedence over these
RFC 822 defined options. If both -f and -i options are omitted then the
RFC 821 MAIL FROM statement will be defaulted to use the installation-defined
default sender address.


For example you could:
 Code:
blat -i %USERNAME%@%COMPUTERNAME% ...

Top
#201190 - 2010-12-17 12:21 PM Re: Urgent request - key lookup [Re: Richard H.]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
In your sample script you may change the following variables accordingly:
 Code:
	$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 Offline
Seasoned Scripter
****

Registered: 2006-08-16
Posts: 686
Loc: Maryland, USA
Following Glen's suggestion, here is some untested code:

 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
#201193 - 2010-12-17 01:40 PM Re: Urgent request - key lookup [Re: Richard H.]
sparkie Offline
Getting the hang of it

Registered: 2010-09-14
Posts: 92
Loc: UK
 Originally Posted By: Richard H.
In your sample script you may change the following variables accordingly:
 Code:
	$Sender = @USERID+"@@"+@WKSTA+".blah.com"
	$Body = '"My Outlook Profile is Outlook, I am workstation '+@WKSTA+'"


This is what I went for, but thanks to everyone. Btw you missed a ' but you can be excused for that \:\)

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'?

Top
#201194 - 2010-12-17 02:54 PM Re: Urgent request - key lookup [Re: sparkie]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
 Originally Posted By: sparkie
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.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#201203 - 2010-12-17 04:18 PM Re: Urgent request - key lookup [Re: sparkie]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
 Code:
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:
 Code:
$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 Offline
Getting the hang of it

Registered: 2010-09-14
Posts: 92
Loc: UK
 Originally Posted By: Les
 Originally Posted By: sparkie
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
Page 2 of 2 <12


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 382 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.063 seconds in which 0.024 seconds were spent on a total of 15 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org