#135676 - 2005-03-16 10:57 AM
Shorten PC-Name and set to variable
|
Anonymous
Anonymous
Unregistered
|
Hi@all, we have a new network-environment. In our concept, we use 10 characters for the pc-name. The problem is: our old enterprise-software has to identify the PC from a variable but can only handle 8 characters.
What i want to do is, to read the pc-name (10char), shorten 2 characters and write the new string (8char) to a environment-variable "term". the name is e.g ROCDTWT012 and shoult be shortened to RODWT012. Is there a way to solve that problem? I'm a noob in scripting and kixstart, so is there somebody who has a script or who can tell me how to do? thanks a lot, bene
|
Top
|
|
|
|
#135678 - 2005-03-16 01:48 PM
Re: Shorten PC-Name and set to variable
|
Anonymous
Anonymous
Unregistered
|
Hi Patrick, thanks for the fast help. Yes, it's always the same characters to be cut off. Unfortunately, it doesn't work. I added these lines to my loginscript:
; Set Term ID IF INGROUP ("PO-TermID") <tab>$=@WKSTA <tab>$=SubSTR($,1,2)+SubSTR($,4,1)+SubSTR($,6) <tab>Set "term="+$
, but the whole workstationname is set to term.
I dont understand line 2 of your script - would it be complicated to explain for me ( = bloody noob)
thx Bene
|
Top
|
|
|
|
#135680 - 2005-03-16 02:59 PM
Re: Shorten PC-Name and set to variable
|
Anonymous
Anonymous
Unregistered
|
thank you, jooel! sounds easy and logical. but it still doesn't work. the whole pc-name with 10 letters is written to temp. any ideas?
|
Top
|
|
|
|
#135683 - 2005-03-16 04:17 PM
Re: Shorten PC-Name and set to variable
|
bene
Fresh Scripter
Registered: 2005-03-16
Posts: 13
Loc: Germany
|
Seems, that I'm too stupid for that
At least, I arrived to register my name for that Board
I also tried to Print $ in a Message-Box with the command
MESSAGEBOX (Term is $,termvariable, 0)
I do not get any output from Kix. Is there a command like "pause" and "echo" in winnt-commandline?
I think I'll have to read a lot to understand, how kixstart is working. damn, i don't have the time for that - i thought, i could just add those two lines to our loginscript and thats it.
what should i do now?
@richard: our enterprise-software needs to identify the pc to send the printjobs to the right printer. the variable is easiest to be handled as environment-variable
Edited by bene (2005-03-16 04:22 PM)
|
Top
|
|
|
|
#135684 - 2005-03-16 04:35 PM
Re: Shorten PC-Name and set to variable
|
bene
Fresh Scripter
Registered: 2005-03-16
Posts: 13
Loc: Germany
|
Quote:
substr() - returns a substring of string RETURN_VALUE = substr(STRING_TO_CUT,START_POSITION,LENGTH_OF_SELECTION)
substr($,1,2)+SubSTR($,4,1)+SubSTR($,6)
why not substr($,1,2)+SubSTR($,4,1)+SubSTR($,6,5)
Is the command case-sensitive?
|
Top
|
|
|
|
#135686 - 2005-03-16 04:56 PM
Re: Shorten PC-Name and set to variable
|
bene
Fresh Scripter
Registered: 2005-03-16
Posts: 13
Loc: Germany
|
Quote:
Before trying to implement it into the logon script, try it first as a short scriptlet run from a DOS prompt.
I tried to do so, but nothing happend. How can i test the basic funcionality of Kix?
I dont know if it's usefull: im running W2k SP4 as client w2k3 as server
|
Top
|
|
|
|
#135688 - 2005-03-16 05:38 PM
Re: Shorten PC-Name and set to variable
|
bene
Fresh Scripter
Registered: 2005-03-16
Posts: 13
Loc: Germany
|
thats exactly what i did (from a network drive) - now i know that this doesn't work. but on the local drive of the server it also didn't work
i did what you said. a tiny mistake in the script and now im getting a result. $ is the name with the cut of letters (lines 1 and 2 are working), but the variable is not set. the output from line 4 works. now, the syntax of the script is: " $=@WKSTA $=SubSTR($,1,2)+SubSTR($,4,1)+SubSTR($,6) Set "term="+$ "the Term should be: "$ ? get $ @kix "
is the command Set "term="+$ correct?
|
Top
|
|
|
|
#135690 - 2005-03-16 05:54 PM
Re: Shorten PC-Name and set to variable
|
bene
Fresh Scripter
Registered: 2005-03-16
Posts: 13
Loc: Germany
|
firstly, in Line 4, there was a " missing- there was no output, so i thought, the script wouldn't run at all.
then, i tried to run kix32 from a mapped network-drive.
and finaly, using a variable needs a logoff after creating it! => I am so stupid!
Thank you for all your help an patience, sorry for wasting your time!!!
I think, now I can test and implement that to my loginscript, myself.
Have a nice evening, Bene
|
Top
|
|
|
|
#135691 - 2005-03-16 05:59 PM
Re: Shorten PC-Name and set to variable
|
NTDOC
Administrator
Registered: 2000-07-28
Posts: 11623
Loc: CA
|
Using the environment variable depends on when you're going to use it. Are you going to use it during the logon script or after?
From the manual
Quote:
SetL
Action: Sets environment variables in the local environment that you see when you start a program from within a KiXtart script.
Syntax: SETL "variable=string"
Remarks: This command does not affect the current environment. If you start KiXtart from a batch file, any commands in the batch file that are run after KiXtart exits do not see changes made by the SET or SETL commands. If you want to run batch files or programs that depend on settings set by KiXtart, start them from KiXtart using SHELL or RUN.
SETL sets the value of @ERROR.
See Also: Set, SetM
Here is some example code to allow you to use the environment AFTER the logon script completes.
Code:
Break On
Dim $PC,$Admin,$PCSet
$PC=@WKSTA
$PC=SubSTR($PC,1,2)+SubStr($PC,4,1)+SubStr($PC,6)
? 'The value for PC is: ' + $PC
; line above so you can see it displayed on the DOS Console
$Admin=IIf(InGroup(@WKSTA+'\'+SidToName('S-1-5-32-544'))-1+@INWIN=1,'Yes','No')
If $Admin='Yes'
$PCSet=WriteValue('HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment','TERM',$PC,REG_SZ)
Else
$PCSet=WriteValue('HKCU\Volatile Environment','TERM',$PC,REG_SZ)
EndIf
Edited by NTDOC (2005-03-16 06:22 PM)
|
Top
|
|
|
|
#135694 - 2005-03-17 03:12 PM
Re: Shorten PC-Name and set to variable
|
bene
Fresh Scripter
Registered: 2005-03-16
Posts: 13
Loc: Germany
|
Hi NTDOC, thanks for your suggestions, but the variable will be set while first login after installation, the user needs it earliest after 3rd login. so i'll keep it as simple as possible.
I completed the script: to work on terminalservers, I need to identify the name of the client-pc. we have old clients (name less than 8char) and new clients (exactly 10 char) so for a user, i have to decide, wether he is working on terminalserver or localPC. if working on terminalservers i have to decide, wether a new pc (10char) or a old pc (<8char) is in use. so the script is something like this:
If not "%Clientname%"="" $="%Clientname%" $x=len(%clientname%) IF $x<9 Set "term="+$ Else $=SubSTR($,1,2)+SubSTR($,4,1)+SubSTR($,6) Set "term="+$ EndIF Else $=@WKSTA $=SubSTR($,1,2)+SubSTR($,4,1)+SubSTR($,6) Set "term="+$ EndIF
Perhaps not the best way to solve that, but it seems to work... greetz from bavaria, bene
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 248 anonymous users online.
|
|
|