Page 1 of 2 12>
Topic Options
#120945 - 2004-06-09 09:59 PM Writeline Readline
momentum Offline
Fresh Scripter

Registered: 2004-06-09
Posts: 17
Hello

I think what i am after is possible, but i'm not having much luck!

What i am trying to do is...


READ a line of text in .txt file

IF the isn't a file, or isn't text... open a website

IF the line of text MATCHES "@YEAR @MONTHNO @MDAYNO"
then do nothing,

BUT, IF the line DOES NOT equal "@YEAR @MONTHNO @MDAYNO" open a website AND write the value "@YEAR @MONTHNO @MDAYNO" to the text file.



so basically, i want a webpage to load when a user logs on, but only the first time they log on that day, after the first time dont show it till tomorrow.




thankyou for any help


Edited by momentum (2004-06-09 10:01 PM)

Top
#120946 - 2004-06-09 10:16 PM Re: Writeline Readline
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Forget files... just write to HKCU.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#120947 - 2004-06-09 10:22 PM Re: Writeline Readline
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
I agree with Les...Something as simple as this should do tha trick..

Code:
$key = "HKCU\Software\YourCompany\pagelaunch"

$value = "lastlaunched"
$page = "http://www.kixtart.org/ubbthreads"

$lastlaunched = ReadValue($key,$value)

If $lastlaunched <> @Date
$null = WriteValue($key,$value,@Date,REG_SZ)
$ie = ReadValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\IEXPLORE.EXE","")
Run $ie+" "+$page
Endif



Edited by CitrixMan (2004-06-09 11:01 PM)

Top
#120948 - 2004-06-09 10:28 PM Re: Writeline Readline
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Well... I would not put it in HKCU\Software\KiXtart\ but rather in HKCU\Software\MyCompany\.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#120949 - 2004-06-09 10:28 PM Re: Writeline Readline
momentum Offline
Fresh Scripter

Registered: 2004-06-09
Posts: 17
Thankyou for your reply (and sorry for cross posting )

the only reason i wanted to go down the road of files, is that its for a school network i manage.

The idea was, is the fist time each day a student logs on, our news page on the intranet opens, and doesn't the next time untill the following day.

because students use different computer, and have mandatory profiles i dont think adding this info to the registry is a possiblity.

any ideas?

Top
#120950 - 2004-06-09 10:30 PM Re: Writeline Readline
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Yeah, well, why didn't you tell us that in the first place. Write it to an INI file then with WriteProfileString().
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#120951 - 2004-06-09 10:32 PM Re: Writeline Readline
momentum Offline
Fresh Scripter

Registered: 2004-06-09
Posts: 17
I am very sorry les,

Thats why i thought it would be possible with readwrite, and didn't even mention the registry.

Top
#120952 - 2004-06-09 10:41 PM Re: Writeline Readline
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
HEHEE
Don't be getting too serious on us.

INI files are easier than Open()/Close() ReadLine()/WriteLine(). I wrote a FAQ on that.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#120953 - 2004-06-09 10:45 PM Re: Writeline Readline
momentum Offline
Fresh Scripter

Registered: 2004-06-09
Posts: 17
I know i'm a pain in the a**e, but how would i go about using an .ini file.

I tried the script above on my machine and works perfectly, so i assume its just an alteration to it?

Top
#120954 - 2004-06-09 11:00 PM Re: Writeline Readline
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
So would you be writing the file to a network share or something then? Wouldnt a file on the local machine get wiped out by the mandatory profile as well?
Top
#120955 - 2004-06-09 11:05 PM Re: Writeline Readline
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
I've been dragging my heels figuring that Shane would knock it off before I did.
Code:
Break On
$INI = 'C:\LastLaunched.ini'

$page = 'http://www.kixtart.org/ubbthreads'

$lastlaunched = ReadProfileString($INI,'Intranet','lastlaunched')

If $lastlaunched <> @Date
$null = WriteProfileString($INI,'Intranet','lastlaunched',@Date)
$ie = ReadValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\IEXPLORE.EXE","")
Run $ie+" "+$page
Endif

_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#120956 - 2004-06-09 11:05 PM Re: Writeline Readline
momentum Offline
Fresh Scripter

Registered: 2004-06-09
Posts: 17
thankyou for all this help.

Ideally, i would want to write this info to the users home area (which is the H:\ drive)

or, to a share like: ( \\"SERVER"\"USERNAME"$ )

which ever is easist or which ever way is the better one!

Top
#120957 - 2004-06-09 11:08 PM Re: Writeline Readline
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
Was just fixing to post...
Top
#120958 - 2004-06-09 11:08 PM Re: Writeline Readline
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Then just change the path on this line:
$INI = 'C:\LastLaunched.ini'
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#120959 - 2004-06-09 11:11 PM Re: Writeline Readline
momentum Offline
Fresh Scripter

Registered: 2004-06-09
Posts: 17
Les,

once again, cheers. the respond time around here is second to none!

would i be able to add an "IF" to all of that as below:

$USERNAMEPREFIX = SUBSTR(@USERID,1,2)

IF $USERNAMEPREFIX = "97"

$INI = 'C:\LastLaunched.ini'
$page = 'http://www.kixtart.org/ubbthreads'
$lastlaunched = ReadProfileString($INI,'Intranet','lastlaunched')If $lastlaunched <> @Date $null = WriteProfileString($INI,'Intranet','lastlaunched',@Date) $ie = ReadValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\IEXPLORE.EXE","") Run $ie+" "+$pageEndif

ENDIF

so, if the user "97evanst" logs on, the 'lastlaunch' runs. If "02jonesv" logs on it doesn't.

is that right?


Top
#120960 - 2004-06-09 11:17 PM Re: Writeline Readline
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
Looks ok to me...I would recommend keeping proper indenting to make it easier to understand though. So something like this should work fine...

Code:
$USERNAMEPREFIX = SUBSTR(@USERID,1,2) ; can also use $USERNAMEPREFIX = Left(@USERID,2)

IF $USERNAMEPREFIX = "97"
$INI = 'H:\LastLaunched.ini'
$page = 'http://www.kixtart.org/ubbthreads'
$lastlaunched = ReadProfileString($INI,'Intranet','lastlaunched')
If $lastlaunched <> @Date
$null = WriteProfileString($INI,'Intranet','lastlaunched',@Date)
$ie = ReadValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\IEXPLORE.EXE","")
Run $ie+" "+$page
Endif
ENDIF


Top
#120961 - 2004-06-09 11:31 PM Re: Writeline Readline
momentum Offline
Fresh Scripter

Registered: 2004-06-09
Posts: 17
i promiss i will go to bed after this question.

is it ok to put:

IF $USERNAMEPREFIX = "97" or "98" or "99"

thanks

Top
#120962 - 2004-06-09 11:33 PM Re: Writeline Readline
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
Close...It would be something more like this...

IF $USERNAMEPREFIX = "97" or $USERNAMEPREFIX = "98" or $USERNAMEPREFIX = "99"

Or if you want it to be for anyone in the 90's...

If Left($USERNAMEPREFIX,1) = "9"

Top
#120963 - 2004-06-09 11:40 PM Re: Writeline Readline
momentum Offline
Fresh Scripter

Registered: 2004-06-09
Posts: 17
i know i promissed... and i will go to bed after this VERY last question.

is there any sort of switch i can add to the script you compiled for me to make sure the IE window is maximised.

also, would this be possible:

IF $PREFIX = "97" or $PREFIX = "98" or InGroup("staff")
do intranet thing


I am very very thankful for your all your help

Top
#120964 - 2004-06-09 11:56 PM Re: Writeline Readline
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
Try this out...

Code:
$PREFIX = SUBSTR(@USERID,1,2)
IF $PREFIX = "97" or $PREFIX = "98" or InGroup("staff")
$INI = 'H:\LastLaunched.ini'
$page = 'http://www.kixtart.org/ubbthreads'
$lastlaunched = ReadProfileString($INI,'Intranet','lastlaunched')
If $lastlaunched <> @Date
$null = WriteProfileString($INI,'Intranet','lastlaunched',@Date)
$ie = ReadValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\IEXPLORE.EXE","")
Run '%comspec% /c Start "" /B /MAX "'+$ie+'" "'+$page+'"'
Endif
ENDIF


Top
Page 1 of 2 12>


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

Who's Online
0 registered and 764 anonymous users online.
Newest Members
ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder, M_Moore
17887 Registered Users

Generated in 0.082 seconds in which 0.028 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