#120945 - 2004-06-09 09:59 PM
Writeline Readline
|
momentum
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
|
|
|
|
#120947 - 2004-06-09 10:22 PM
Re: Writeline Readline
|
ShaneEP
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
|
|
|
|
#120949 - 2004-06-09 10:28 PM
Re: Writeline Readline
|
momentum
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
|
|
|
|
#120951 - 2004-06-09 10:32 PM
Re: Writeline Readline
|
momentum
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
|
|
|
|
#120953 - 2004-06-09 10:45 PM
Re: Writeline Readline
|
momentum
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
|
|
|
|
#120956 - 2004-06-09 11:05 PM
Re: Writeline Readline
|
momentum
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
MM club member
   
Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
|
Was just fixing to post...
|
|
Top
|
|
|
|
#120959 - 2004-06-09 11:11 PM
Re: Writeline Readline
|
momentum
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
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
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
|
|
|
|
#120963 - 2004-06-09 11:40 PM
Re: Writeline Readline
|
momentum
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
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
|
|
|
|
Moderator: Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart
|
1 registered
(mole)
and 759 anonymous users online.
|
|
|