Page 1 of 1 1
Topic Options
#204623 - 2012-04-03 01:04 AM Passing a result back to Kixtart
Devlin7 Offline
Fresh Scripter

Registered: 2010-10-21
Posts: 13
Loc: NZL
Hi,

I have got a simple task for kix that I have mastered in a batch script but want to place it in my logon kix script. I want to read the registry to see which server the roaming profile is being stored on.

The result will be \\server\profiles$\username.v2 [the new Windows 7 profile path] and this will be saved as $new_prof

I also want a variable $old_prof which is the same as $new_prof except that is doesn't have the .v2 extension

Basically, I want to run this from within my kix script

shell '%comspec% /c for /f "tokens=3" %%C in ("c:\windows\system32\reg.exe" query "hklm\software\microsoft\Windows NT\CurrentVersion\Profilelist" /s /f centralprofile ^| find "REG_SZ") do set $new_prof=%%c'

Then I check to see if $new_prof exists before proceeding at which point it fails.

1) How do I check what I am getting in variable $new_prof if anything?
2) How might I truncate $new_prof to be $old_prof [ie. missing the .v2]

Thanks in advance for your help



Edited by Devlin7 (2012-04-03 01:23 AM)

Top
#204624 - 2012-04-03 01:53 AM Re: Passing a result back to Kixtart [Re: Devlin7]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
Is there a reason you dont want to simply read the registry value straigh to a variable inside of kix, instead of trying to use a batch script and passing it in?
Top
#204625 - 2012-04-03 01:58 AM Re: Passing a result back to Kixtart [Re: ShaneEP]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
Something like this should work. I dont have a server to test it on, so Im kind of guessing about the registry key to read.

 Code:
$new_prof = ReadValue("HKLM\Software\Microsoft\Windows NT\CurrentVersion\ProfileList","centralprofile")
$old_prof = Left($new_prof,-3)

Top
#204626 - 2012-04-03 02:10 AM Re: Passing a result back to Kixtart [Re: ShaneEP]
Devlin7 Offline
Fresh Scripter

Registered: 2010-10-21
Posts: 13
Loc: NZL
Hi ShaneEP,

I went with the batch script option rather than kix because I couldn't work out how to make kix search the registry for a value. You see that each user has their own entry under PROFILELIST. I have cut and pasted your two lines into my script but it is still ending early when I run
if exist($new_prof)

Is there an easy way to see what is set for the value $new_prof?


Edited by Devlin7 (2012-04-03 02:22 AM)

Top
#204627 - 2012-04-03 03:04 AM Re: Passing a result back to Kixtart [Re: Devlin7]
Devlin7 Offline
Fresh Scripter

Registered: 2010-10-21
Posts: 13
Loc: NZL
Shane,

Just wanted to say thanks for your help. The following seems to work
$new_prof = ReadValue("HKLM\Software\Microsoft\Windows NT\CurrentVersion\ProfileList\@sid","centralprofile")
$old_prof = Left($new_prof,-3)

Top
#204628 - 2012-04-03 02:55 PM Re: Passing a result back to Kixtart [Re: Devlin7]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Consider not embedding macros or vars in strings.

$new_prof = ReadValue('HKLM\Software\Microsoft\Windows NT\CurrentVersion\ProfileList\'+@sid,'centralprofile')
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

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
1 registered (mole) and 494 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.054 seconds in which 0.023 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