Page 1 of 1 1
Topic Options
#172805 - 2007-01-16 03:00 AM Run a command based on the result of a registry key
jon Offline
Fresh Scripter

Registered: 2007-01-15
Posts: 11
Within my scipt, I need to run a command to check certain criteria within the registy and execute depending on the result.

Only if the hostname is a specific server and if a specific key exsists with a specfic value do I want the .reg file to import.

Below is an example of what I want but I'm unsure if this is correct termonology and I can't find any specific examples of this on the forum. The manual states another option READVALUE but I can't tell which one is the correct command.


IF @WKSTA="TS_SERVER"
IF READTYPE ("HKEY_CURRENT_USER\Software\Program\Value_Name", "Value_data")
Shell "regedit /s" "\\servername\share\import.reg"
ENDIF
ENDIF


Thanks in advance for any assistance.

Top
#172807 - 2007-01-16 03:14 AM Re: Run a command based on the result of a registry key [Re: jon]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11611
Loc: CA
You're close


1. What version of KiXtart are you using?

2. What are the exact details (names/reasons) to check to verify if you want it to run ?

You would use ReadValue if you're making a determination of the data from the registry. The Type only tells you the data type which I don't think is what you're looking for.

.

Top
#172808 - 2007-01-16 03:23 AM Re: Run a command based on the result of a registry key [Re: NTDOC]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Your shell line is wrong.
Shell 'regedit /s "\\servername\share\import.reg"'
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#172818 - 2007-01-16 11:46 AM Re: Run a command based on the result of a registry key [Re: jon]
jon Offline
Fresh Scripter

Registered: 2007-01-15
Posts: 11
Thank you for your replies...

I have edited the two lines to the correct ReadValue and Shell commands and edited the REG_SZ info to read a little clearer...

IF @WKSTA="TS_SERVER"
IF ReadValue ("HKEY_CURRENT_USER\Software\Program\UserName", "NONUSER")
Shell 'regedit /s "\\servername\share\import.reg"'
ENDIF
ENDIF

I am running the very latest version of Kixtart (KiX2010_453) and the Registry values that I am reading are REG_SZ and in relation to a peice of software on a Terminal Server. The software has been installed but requires configuring, per user, on their first login. Once configured, the kixtart commands are no longer required which is why I need to check the value of the registry key to determine whether it's the default entry or not. If so, then it will import a registry key but if it's not the default entry, kixtart will ignore the command and carry on with the script.

This still requires a little intervention to get the software running once the user is logged in. Therefore, once I have the correct command formating, I could query the name of the user and import a pre-made .reg key based on their username and it would be fully configured.

It's just I'm not sure I'm calling the commands correctly from the login script to either run the command if a registry is of a certain value or to ignore it and carry on with the rest of the script if it's not.

Thanks again for any help.

Top
#172827 - 2007-01-16 03:25 PM Re: Run a command based on the result of a registry key [Re: jon]
jon Offline
Fresh Scripter

Registered: 2007-01-15
Posts: 11
I am sooo close but when ever I test, I don't get the desired result.

This is the code I have now...


IF @WKSTA="TS-SERVER"
$User=ReadValue('HKEY_CURRENT_USER\Software\GoldMine\GoldMine Link for Microsoft Outlook','GMUserName')
If $User 'NONUSER'
Shell 'regedit /s "\\MAIN-SERVER\Support\Goldmine\GISMO\GISMO.reg"'
?"GISMO Installed for " @userid
Else
?"GISMO Already Installed for " @userid
EndIf


When I test this, the key imports fine when the value is set to NONUSER. However, if I change this value to USER1, within the registry and then run the script again, it still imports the .reg file. I want it to ignore the import .reg command if anything but NONUSER is the value of the key.

What have I got wrong?


Edited by jon (2007-01-16 03:27 PM)

Top
#172828 - 2007-01-16 03:33 PM Re: Run a command based on the result of a registry key [Re: jon]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4520
Loc: USA
(Untested)
Code:
 
IF @WKSTA="TS-SERVER"
  $User=ReadValue('HKEY_CURRENT_USER\Software\GoldMine\GoldMine Link for Microsoft Outlook','GMUserName')
  If $User='NONUSER'
    Shell 'regedit /s "\\MAIN-SERVER\Support\Goldmine\GISMO\GISMO.reg"'
    ?"GISMO Installed for " + @userid
  Else
    ?"GISMO Already Installed for " + @userid
  EndIf
EndIf


Looks like you were missing an "=" after If $user and an Endif at the end.

Top
#172837 - 2007-01-16 05:39 PM Re: Run a command based on the result of a registry key [Re: Allen]
jon Offline
Fresh Scripter

Registered: 2007-01-15
Posts: 11
Perfect! Works like a dream now.

Thanks for your help.

Top
#182238 - 2007-11-05 02:27 AM Re: Run a command based on the result of a registry key [Re: jon]
Arthur Offline
Fresh Scripter

Registered: 2007-11-05
Posts: 10
good
Top
Page 1 of 1 1


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

Who's Online
0 registered and 310 anonymous users online.
Newest Members
Praveer, Ollero, rayyo, Foxlicht, DonChild
17742 Registered Users

Generated in 0.04 seconds in which 0.012 seconds were spent on a total of 13 queries. Zlib compression enabled.

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