Page 1 of 2 12>
Topic Options
#201148 - 2010-12-14 09:35 AM Urgent request - key lookup
sparkie Offline
Getting the hang of it

Registered: 2010-09-14
Posts: 92
Loc: UK
I need to create a registry lookup of a key to somehow contact ICT if it exists. I currently use this command to lookup for another item.

IF ReadValue

Is this possible?

Many thanks

Top
#201149 - 2010-12-14 09:59 AM Re: Urgent request - key lookup [Re: sparkie]
sparkie Offline
Getting the hang of it

Registered: 2010-09-14
Posts: 92
Loc: UK
Digging further maybe I can use the sendmessage to identify the user sending the message
Top
#201150 - 2010-12-14 11:30 AM Re: Urgent request - key lookup [Re: sparkie]
sparkie Offline
Getting the hang of it

Registered: 2010-09-14
Posts: 92
Loc: UK
Ok, I'm getting nowhere fast with this. Using this context but it seems the lookup is not working. If I omit the KeyExist the messge gets submitted locally.

IF KeyExist ("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\Outlook”)
$RC = SendMessage("ELWY", "Test")
ELSE
?"do nothing"
ENDIF

Top
#201151 - 2010-12-14 01:19 PM Re: Urgent request - key lookup [Re: sparkie]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
That double-quote character at the end of the KeyExist line is not a normal double quote, it is a "smart" quote.

You get these if you copy'n'paste from the manual or if you use something like Word to edit your script.

Replace it with a normal quote character and you should get a better result.

Top
#201152 - 2010-12-14 04:06 PM Re: Urgent request - key lookup [Re: Richard H.]
sparkie Offline
Getting the hang of it

Registered: 2010-09-14
Posts: 92
Loc: UK
Thanks Richard, I had a play around and reverted to this but I have a couple of issues.

;$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
SHELL "sc config messenger start= demand"
SHELL "NET START Messenger"
SHELL "sc config messenger start= disabled"
$RC = SendMessage("MATAURA", "Test")
ELSE
?"Do nothing"

Endif

It seems to work (sending test message to itself at the moment) but since my PC is Vista, it doesn't have the messenger service so it's becoming difficult to test.

Any ideas?

Top
#201153 - 2010-12-14 04:30 PM Re: Urgent request - key lookup [Re: sparkie]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
Have a look at Blat.exe. A simple command line e-mail tool. I use it a lot and it works great.

 Code:
$Sender = "sender@@yourdomain.com"
;Set a recipient address.
$Recipients = "recipient@@yourdomain.com"
;Set the subject.
$Subject = '"Subject"'
;SMTP server to be used for sending the message.
$smtpserver = "mailserver"
;Create the body text.
$Body = '"Message body"'
;Send the message.
$Send = BlatMailerNoAttachment($Recipients, $Sender, $Subject, $Body, $smtpserver)

Function BlatMailerNoAttachment($Recipient, $Sender, $Subject, $Body, $smtpserver)
	Dim $MailerLine
	$MailerLine = 'patht\blat.exe -' + ' -to ' + $recipient + ' -f ' + $sender + ' -subject ' + $subject + ' -body ' + $body + ' -server ' + $smtpserver + ' -q '
	Shell $MailerLine
EndFunction
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#201154 - 2010-12-14 05:40 PM Re: Urgent request - key lookup [Re: Mart]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
There's actually an easy method for using Blat from a central server illustrated in fair detail in the Script Vault. This allows any kix script to send email simply by writing a file and moving it to a central file share. There, a Kix script monitors the folder for new files and extracts the information, using it as arguments to Blat. Blat then sends the message file contents as the email body.

This allows any computer to send an automated message without anything more than Kixtart available. No need to have Blat, configure it's registry settings, or anything else on the PC. Depending on how fast you cycle the monitor script, messages can arrive in your inbox within 30 seconds or so.

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

Top
#201155 - 2010-12-14 06:06 PM Re: Urgent request - key lookup [Re: Glenn Barnas]
sparkie Offline
Getting the hang of it

Registered: 2010-09-14
Posts: 92
Loc: UK
I had a quick play with Blat and it didn't work. All I want to do is send a message to either a computer or an email address (internal domain) when a domain user logs in on a PC and a certain key exists.

I'm open to suggestions

Top
#201157 - 2010-12-14 06:57 PM Re: Urgent request - key lookup [Re: sparkie]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
To send email, you need Blat or an equivelent application.

To send a message, you need the messaging service running (security risk) or need to write your own (complex).

Taking the time to properly configure Blat on a central server will be worth the 30 minutes of effort to install and configure it. Once done, any script can easily send a message via email.

Some things to consider with email - Blat needs to know the proper SMTP server address and may require a valid user account to send mail. The server sending mail via Blat may need to be configured on the mail server as an authorized relay host. This is just part of configuring email within your network.

Another solution, also in the Script Vault, would be to drop message files in the share of a central server. A script running there would process the dropped files, either sending email (again, with blat or similar tool), printing a report, or displaying a popup message. This way, all of the complex configuration is done on one computer.

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

Top
#201166 - 2010-12-15 09:21 AM Re: Urgent request - key lookup [Re: sparkie]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Blat it a 3rd party application, did you install it?

http://www.blat.net/

Also bear in mind that many companies (including mine) block outgoing SMTP on desktops for security reasons to stop mass mailers and virus propogation. McAfee's AV product does this out of the box for example.

You can test SMTP connectivity by telnet-ing from your desktop to port 25 on your SMTP server. If you can open the connection and get a response from EHLO then you're OK. Here is an example:
 Quote:
[root@xxx00006 ~]# telnet smtp.xxx.com 25
Trying 99.99.99.99...
Connected to smtp.xxx.com (99.99.99.99).
Escape character is '^]'.
220 xxx.xxx.com Microsoft ESMTP MAIL Service, Version: 6.0.3790.4675 ready at Wed, 15 Dec 2010 08:09:56 +0000
ehlo
250-xxx.xxx.com Hello [99.99.99.99]
250-TURN
250-SIZE
250-ETRN
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-8bitmime
250-BINARYMIME
250-CHUNKING
250-VRFY
250-X-EXPS GSSAPI NTLM LOGIN
250-X-EXPS=LOGIN
250-AUTH GSSAPI NTLM LOGIN
250-AUTH=LOGIN
250-X-LINK2STATE
250-XEXCH50
250 OK
quit
221 2.0.0 smtp.xxx.com Service closing transmission channel

Top
#201167 - 2010-12-15 12:13 PM Re: Urgent request - key lookup [Re: Richard H.]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
 Originally Posted By: Richard H.
...bear in mind that many companies (including mine) block outgoing SMTP on desktops for security reasons to stop mass mailers and virus propogation. McAfee's AV product does this out of the box for example.
Exactly why the Kix mail service demonstrated in the script vault was developed. Even if servers aren't permitted to send mail, allowing a single server to send mail (or running the service on the mail server itself) is easy to configure. It all comes down to the security configuration and policies of the environment.

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

Top
#201171 - 2010-12-15 05:46 PM Re: Urgent request - key lookup [Re: Glenn Barnas]
sparkie Offline
Getting the hang of it

Registered: 2010-09-14
Posts: 92
Loc: UK
No I haven't installed Blat. I downloaded the files and thought maybe I could copy the files to a folder and the script above could then be edited with the relevant credentials to run the .exe file. I'm thinking this is not the case.

I just want a simple way of reporting if a key exists when a user logs in based upon a current user key and since Messenger is disabled on everyones computer, it sounds like this is a problem.

Is there an alternative to a message?

Top
#201173 - 2010-12-15 06:19 PM Re: Urgent request - key lookup [Re: sparkie]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
Again, look in the script vault - there's a package for centralized reporting. It requires a bit of customization to your specific needs, but it would be minimal (client side - read the value and write the result, server side, read the value, add to a table, database, or some report document). The hard stuff is done - managing the reciept of many individual updates and consolidating the information. Not as real-time as message or email, but effective.

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

Top
#201176 - 2010-12-16 10:00 AM Re: Urgent request - key lookup [Re: Glenn Barnas]
sparkie Offline
Getting the hang of it

Registered: 2010-09-14
Posts: 92
Loc: UK
Ok, Blat seems to be working when I login to our Terminal Servers (2008) as a domain user, but not when I login to an XP domain PC.

One thing I need to do is have the email encorporate some kind of info to advise us which user/computer the email was sent from.


Edited by sparkie (2010-12-16 10:08 AM)

Top
#201177 - 2010-12-16 10:05 AM Re: Urgent request - key lookup [Re: sparkie]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Did you run the test as I advised earlier from your client PC?

If you are blocking port 25 from the client you will not be able to do simple direct mail and will have to use a different technique.

If you want something very simple then just write the status to a file on a server share, then just review the file regularly. If you have a lot of clients you might want to use multiple files.

Top
#201178 - 2010-12-16 10:10 AM Re: Urgent request - key lookup [Re: Richard H.]
sparkie Offline
Getting the hang of it

Registered: 2010-09-14
Posts: 92
Loc: UK
Richard,

That's exectly the one I'm running. Also I need to define who the email was coming from

Top
#201179 - 2010-12-16 11:48 AM Re: Urgent request - key lookup [Re: sparkie]
sparkie Offline
Getting the hang of it

Registered: 2010-09-14
Posts: 92
Loc: UK
I'm going to scrap this idea since the workstations are locked down and too much time is being spent firefighting a simple email solution. Blat works using an out of box scenario, but not if ports/ etc aren't available.
Top
#201180 - 2010-12-16 11:57 AM Re: Urgent request - key lookup [Re: sparkie]
BradV Offline
Seasoned Scripter
****

Registered: 2006-08-16
Posts: 686
Loc: Maryland, USA
Have the script write an INI file on a central server. Use the workstation name as the file name. Then write parameters as needed. Such as "user=fred", etc.

Then you can have a server process enumerate the directory; read the files it finds; send the e-mail; delete the file.

Top
#201181 - 2010-12-16 12:20 PM Re: Urgent request - key lookup [Re: BradV]
sparkie Offline
Getting the hang of it

Registered: 2010-09-14
Posts: 92
Loc: UK
 Originally Posted By: BradV
Have the script write an INI file on a central server. Use the workstation name as the file name. Then write parameters as needed. Such as "user=fred", etc.

Then you can have a server process enumerate the directory; read the files it finds; send the e-mail; delete the file.


That seems to be my best solution, are there any examples here so I'm not re-inventing the wheel.

I'll need to to only run if domain user login OS is XP or Vista

Top
#201183 - 2010-12-16 08:07 PM Re: Urgent request - key lookup [Re: sparkie]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
Once again, check the script vault for a mostly ready to run app. The core logic is there, you'll need to use the functions in your own code, since only you know what data you need to collect and write.

The article is titled "Central Data Collection - Kix as a Service" - it's exactly what you need. I mentioned this a few days ago as an alternative to email.

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

Top
Page 1 of 2 12>


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

Who's Online
0 registered and 128 anonymous users online.
Newest Members
SERoyalty, mytar, Gabriel, Alex_Evos, Dansen
17869 Registered Users

Generated in 0.075 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