Page 1 of 1 1
Topic Options
#13638 - 2001-10-26 05:51 PM Removing an entry from a file
Anonymous
Unregistered


I hope this makes sense:

I have a file that I have added 10 computer names i.e comp1. comp2 etc

What I am trying to do is when comp1 logs on the script checks the file and if it apears runs another script (not the problem) and then deletes the entry so it does not run again. The problem I forsee is if all 10 machines logon at the same time there will be a problem with file being locked by another machine.

Any ideas

chris.darling@virgin.net

Top
#13639 - 2001-10-26 06:01 PM Re: Removing an entry from a file
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Chris,

Use an INI File and manipulate with writeprofilestring() / readprofilestring() and Bob's your uncle !

J.

_________________________



Top
#13640 - 2001-10-27 02:31 AM Re: Removing an entry from a file
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
Dear,

Welcome to the board.

Our example which can give you an idea "how to do it":

Your temporary file can looks like:
f.e. script.ini

code:

[script]
comp1=x:\scripts\script1.kix
comp2=x:\scripts\script2.kix
comp3=x:\scripts\script1.kix
comp4=x:\scripts\script1.kix
comp5=x:\scripts\script5.kix


We are extend it to run different kind of scripts for different users.

Your script can looks like:

code:

cls
$script_file="x:\scripts\script.ini"
$script_info=ReadProfileString($script_file,"script",@wksta)
IF (Len($script_info) <> 0)
CALL $script_info
IF (WriteProfileString($script_file,"script",@wksta,"") <> 0)
? "Warning KIX: problem with removing INI entry. error-code @error (@serror)."
ENDIF
ENDIF


greetings.
_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
#13641 - 2001-10-27 03:09 AM Re: Removing an entry from a file
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
The INI file solution described in this thread may not scale well. Have you considered using a call statement such as
code:
if exists("@wksta.kix")
call "@wksta.kix"
del "@wksta.kix"
endif

[ 27 October 2001: Message edited by: Howard Bullock ]

[ 27 October 2001: Message edited by: Howard Bullock ]

_________________________
Home page: http://www.kixhelp.com/hb/

Top
#13642 - 2001-10-27 05:34 AM Re: Removing an entry from a file
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
Dear,

Our example which can give you an idea "how to do it" and with a message part.

Your temporary file can looks like:
f.e. script.ini

code:

[script]
comp1=x:\scripts\script1.kix
comp2=x:\scripts\script2.kix
comp3=x:\scripts\script1.kix
comp4=x:\scripts\script1.kix
comp5=x:\scripts\script5.kix


We are extending it to run different kind of scripts for different users.

Your script can looks like:

code:

cls
$script_file="x:\scripts\script.ini"
$script_info=ReadProfileString($script_file,"script",@wksta)
IF (Len($script_info) <> 0)
IF (Exist($script_info) = 1)
CALL $script_info
IF (WriteProfileString($script_file,"script",@wksta,"") <> 0)
? "Warning KIX: problem with removing INI entry. error-code @error (@serror)."
ENDIF
ELSE
IF (MessageBox("Missing '+Ucase($script_info)+' file.'+CHR(10)+CHR(13)+'inform your helpdesk','Information message',0,5) <> 0)
ENDIF
ENDIF
ENDIF


greetings.

btw: you can modify the MessageBox function to f.e. a WriteProfileString function.
Some like:

code:

IF (WriteProfileString($script_file,"script",@wksta,$script_info+" -missing file-") <> 0)
ENDIF

Also it is possible to use @userid as criteria instead of @wksta to
run a specified script.

_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

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 687 anonymous users online.
Newest Members
ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder, M_Moore
17887 Registered Users

Generated in 0.059 seconds in which 0.031 seconds were spent on a total of 12 queries. Zlib compression enabled.

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