#25886 - 2002-07-25 10:46 PM
Problems with ReadLine @WKSTA
|
WeakLink
Fresh Scripter
Registered: 2002-03-06
Posts: 37
Loc: San Diego
|
Hi All, it's me again.
I have been tasked with converting a logon.bat into KIX (which I am a novice at best). The login.bat currently checks a txt file to see if a PC exists in this file. If it does, it exits....if it doesn't exist, it runs the bat file. It also sends email if the user selects not to run the bat file (I found some info that Bryce posted for BLAT that I will try).
So here's what I have tried:
FIRST TRY ;Open(3, @WKSTA + "\uk-scripts\exclude.txt", 3) = 0 ;If @ERROR=0 ;$X=ReadLine(3) ;IF $X = @WKSTA ; GOTO END ; ELSE ; $Message = "It works!" ; ENDIF ;:END SECOND TRY $Value = "\uk-scripts\exclude.txt" + @WKSTA" If Open(1, $Value) = 0 $Read = ReadLine(1) CLOSE(1) IF $Value = $Read GOTO END ENDIF ELSE $Message = "It works!" ENDIF :END THIRD TRY IF Open(1, "\uk-scripts\exclude.txt") = 0 $x = Readline(1) WHILE @ERROR = 0 IF InStr($x, @WKSTA) CLOSE(1) GOTO END ENDIF ELSE $Message = "It works!" ENDIF :END
I'm sure this is simple enough, but I'm at my wits end and don't have any hair left.
|
|
Top
|
|
|
|
#25888 - 2002-07-25 11:05 PM
Re: Problems with ReadLine @WKSTA
|
Donald_99a
Fresh Scripter
Registered: 2002-03-02
Posts: 6
Loc: Karlsruhe, Germany
|
I think the rigt way is :
IF Open(1, "\uk-scripts\exclude.txt") = 0 ; better is the complete URL like \\SHARENAME\XX $x = Readline(1) WHILE @ERROR = 0 IF $x = "@WKSTA" CLOSE(1) GOTO END EndIf $x = Readline(1) LOOP ELSE $Message = "It works!" ENDIF :END
You can write in the textfile a List with Workstations
-- Donald --
|
|
Top
|
|
|
|
#25889 - 2002-07-25 11:06 PM
Re: Problems with ReadLine @WKSTA
|
WeakLink
Fresh Scripter
Registered: 2002-03-06
Posts: 37
Loc: San Diego
|
Les,
If you are asking for the "physical" location of the file, it is located in the netlogon\uk-scripts directory.
I suspect though you are asking if the file contains only one line....the file looks like this:
PC-1 PC-2 PC-3 etc.
So no, the @WKSTA is not necessarily on the first line.
|
|
Top
|
|
|
|
#25891 - 2002-07-25 11:10 PM
Re: Problems with ReadLine @WKSTA
|
WeakLink
Fresh Scripter
Registered: 2002-03-06
Posts: 37
Loc: San Diego
|
Sorry Lonkero, I wasn't clear. Within the script the user has a choice of either running the script (yes) or not (no). The script will then send an email to the administrator stating the user refused to run the script.
|
|
Top
|
|
|
|
#25892 - 2002-07-25 11:16 PM
Re: Problems with ReadLine @WKSTA
|
WeakLink
Fresh Scripter
Registered: 2002-03-06
Posts: 37
Loc: San Diego
|
The suggestion Donald had didn't seem to work either. Could it be the batch file that's calling the kix file?
%0\..\kix32.exe %0\..\uk-scripts\test.kix
|
|
Top
|
|
|
|
#25894 - 2002-07-25 11:34 PM
Re: Problems with ReadLine @WKSTA
|
WeakLink
Fresh Scripter
Registered: 2002-03-06
Posts: 37
Loc: San Diego
|
Okay guys, IF this script is working, I should get a message "wksta is to be excluded, quitting..." IF the @WKSTA is NOT in the file, correct?
|
|
Top
|
|
|
|
#25897 - 2002-07-26 05:56 PM
Re: Problems with ReadLine @WKSTA
|
WeakLink
Fresh Scripter
Registered: 2002-03-06
Posts: 37
Loc: San Diego
|
Okay, first I would like to thank everyone for their input, I do appreciate it.
I tried the solution Sealeopard suggested:
IF VAL (READPROFILESTRING(@LDRIVE+'\uk-scripts\exclude.ini','Exclude',@WKSTA)) = 1 EXIT 0 ELSE "It works!" ENDIF
and now at least I get the message, but I get it regardless of if the PC is excluded or not. I created the exclude.ini, added the PC's with = 1. The bat file that calls it goes:
@echo off
%0\..\kix32 %0\..\test.kix
pause
Could it be the version of kix that I'm running? 3.62?
Any help would be appreciated. Again, thx all!
|
|
Top
|
|
|
|
#25900 - 2002-07-26 08:04 PM
Re: Problems with ReadLine @WKSTA
|
WeakLink
Fresh Scripter
Registered: 2002-03-06
Posts: 37
Loc: San Diego
|
When I tried READPROFILESTRING(@LDRIVE+'\uk-scripts\exclude.ini','Exclude',@WKSTA), I didn't get a response at all.
I ran it from the command line and received: script error : unable to find/open script !
And calling it from a bat file produced nothing
|
|
Top
|
|
|
|
#25901 - 2002-07-26 08:10 PM
Re: Problems with ReadLine @WKSTA
|
Sealeopard
KiX Master
   
Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
|
|
|
Top
|
|
|
|
#25902 - 2002-07-26 08:41 PM
Re: Problems with ReadLine @WKSTA
|
WeakLink
Fresh Scripter
Registered: 2002-03-06
Posts: 37
Loc: San Diego
|
Lonkero,
I tried your solution and still get the same result: "It works!" is the reply I get whether it value is true or not. I tried 1, 0, yes and it was all the same result. I also subbed the @scriptdir with the same results.
SeaLeopard,
I tried your solution and the value = it works!
$a=READPROFILESTRING(@ldrive+'\uk-scripts\exclude.ini','Exclude',@WKSTA) IF @ERROR ? 'Error encountered : '+@ERROR+' - '+@SERROR ELSE ? 'Value = '+$a ENDIF IF VAL($a)=1 EXIT 0 ELSE "It works!" ENDIF
|
|
Top
|
|
|
|
#25904 - 2002-07-26 09:41 PM
Re: Problems with ReadLine @WKSTA
|
Sealeopard
KiX Master
   
Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
|
Run this code:
code:
$a=READPROFILESTRING(@ldrive+'\uk-scripts\exclude.ini','Exclude','') $a=split($a,chr(10)) for each $comp in $a $b=READPROFILESTRING(@ldrive+'\uk-scripts\exclude.ini','Exclude',$comp) ? 'Computer = '+$comp+' and has assigned value ='+$b next
This will give you the list of computers in the .INI file and their associated values.
BTW, these scripts are so simple that I really have no idea what you can do wrong except maybe have spelling errors. Thus, check for spelling errors, since the code does work for me. [ 26 July 2002, 21:41: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 837 anonymous users online.
|
|
|