Page 2 of 2 <12
Topic Options
#29923 - 2002-09-29 05:29 PM Re: Copying files
Sverre Offline
Getting the hang of it

Registered: 2002-09-29
Posts: 52
Here is the script

code:
;****                                                          ****
;**** Login script for Lorentzen & Stemoco ****
;**** Made 21-22 Sep 2002 by Sverre Munthe ****
;**** Copyright (c) 2002, Lorentzen & Stemoco ****
;**** This script will only work with WinNT or better ****
;**** ****
;**** MunSve 27.09.2002 Added support for Symantec live update ****
;**** MunSve 29.09.2002 Something wrong with copying ls.bmp ****
;**** MunSve 29.09.2002 WinXP machines don't get @primarygroup ****
;**** ****

;****
;**** Setting a few variables for the script
;****
setoption("hidecursor", "on")
settitle("Hi " +@fullname + " you are now being logged on to Lornet, please wait this shouldn't take long")
if ReadValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "RunLogonScriptSync") <> 1
$value = WriteValue ("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "RunLogonScriptSync", "1", "REG_DWORD")
endif

;****
;**** Checking if this is the first time this machine
;**** has logged on to the domain, if it is a file is
;**** created and a line is made about the logon time,
;**** if it isn't a line is made in the file about time
;****
$firsttime = 0
$file = "%0\..\Users\" + @userid + ".log"
if open(1, $file, 4) <> 0
if open(1, $file, 5) = 0
$txt = writeline(1, "First time logged on to domain " + @date + " " + @time + @crlf)
$firsttime = 1
endif
else
$txt = writeline(1, "Logged on to domain from workstation " + @wksta + " " + @date + " " + @time + @crlf)
endif

;****
;**** Making a welcome message if this is the first time
;****
if $firsttime=1
Small
Color b+/n
Box (0,0,24,79,GRID)
Color g/w+
Box (0,9,24,70,FULL)
Color n/w+
AT (1,11) " Welcome to the Lornet domain! "
AT (3,11) " Since this is the first time you are logging on we will "
AT (4,11) " take some time informing you about the Lornet domain as "
AT (5,11) " well as what we in the IT-department can help you with. "
AT (7,11) " The domain Lornet consists of 6 servers that all work "
AT (8,11) " together to give you the best working solution possible "
AT (9,11) "The file-server is where you will save your work and also"
AT (10,11) " run some of your more special programs from "
AT (11,11) "The Exchange-server is where all the e-mail is collected."
AT (12,11) "The MRS-server collects all the e-mail from the Exchange-"
AT (13,11) " server and also receives faxes. "
AT (14,11) " The SQL-server collects, and stores, all the messages "
AT (15,11) " for the Strategic software from the MRS-server. "
AT (16,11) " The Terminal-server lets you work from outside the Oslo "
AT (17,11) " office without having the programs installed on the PC. "
AT (18,11) " The Shipnet-server stores all of the post-fixtures. "
AT (20,11) "If you have any problems with any of the programs or your"
AT (21,11) "PC, we at the IT-department will do our best to help you."
AT (22,11) " You can reach us at 777 during working hours and at 888 "
AT (23,11) " after working hours. From outside dial 22 52 78 88. "
Color g/w+
AT (24,28) "Press a key to continue"
do
until kbhit()
endif

;****
;**** Testing for certain specific dates
;****
$array = @mdayno, @monthno
$today = join($array, "/")

if $today = "1/1" $specialday = "Happy New Year!"
endif

if $today = "1/5" $specialday = ""
endif

if $today = "17/5" $specialday = "Gratulerer med dagen Norge!"
endif

if $today = "24/12" $specialday = "Merry Christmas!"
endif

if $today = "25/12" $specialday = "Merry Christmas!"
endif

if $today = "31/1" $specialday = ""
endif

;****
; **** This next string is for testing
;****
;if $today = "22/9" $specialday = "Some type of text"
;endif

if len($specialday) > 0
Small
$length = len($specialday)
$x1 = ((79 - $length) / 2) - 1
$x2 = 79 - $x1
Color b+/n
Box (0,0,24,79,GRID)
Color b/n
Box (11,$x1+1,15,$x2+1,Å)
Color g/w+
Box (10,$x1,14,$x2,FULL)
Color n/w+
AT (12,$x1+2) $specialday
sleep 3
endif

;****
;**** Adjusting the clock to same as server
;****
SetTime "\\lorfile"

;****
;**** Making a box that shows some data about
;**** his/her machine and the network
;****
$mhz = ""
$mhz = $mhz + @mhz + "MHz"
$diskspace = getdiskspace("c:\")
$diskspace = int($diskspace/1000)
if len($diskspace) > 3
$length = len($diskspace) - 3
$diskspace = left($diskspace, $length) + "." + right($diskspace,3) + "MB"
else
if len($diskspace) < 2
$diskspace = "Harddisk full!"
else
$diskspace = $diskspace + "MB"
endif
endif
Small
Color b+/n
Box (0,0,24,79,GRID)
Color b+/n
Box (6,21,19,61,Å)
Color g/w+
Box (5,20,18,60,FULL)

Color b/w+
AT ( 7,25) "Userid : "
AT ( 8,25) "Full name : "
AT ( 9,25) "Group : "
AT (10,25) "Privilege : "
AT (11,25) "Workstation : "
AT (12,25) "CPU speed : "
AT (13,25) "C-drive : "
AT (14,25) "Domain : "
AT (15,25) "Logon Server : "
AT (16,25) "Current Time : "

Color n/w+
AT ( 7,40) @userid
AT ( 8,40) @fullname
AT ( 9,40) @primarygroup
AT (10,40) @priv
AT (11,40) @wksta
AT (12,40) $mhz
AT (13,40) $diskspace
AT (14,40) @domain
AT (15,40) @lserver
AT (16,40) @time
color w+/w+
;AT (0,0)
Sleep 5

;****
;**** Deleting all nettwork drives and setting
;**** up new ones
;****
Use "*" /delete
$f = "\\lorsql\visma"
$g = "\\lorfile\programs"
$h = "\\lorfile\software"
$i = "\\lorfile\c$"
$j = "\\lorfile\d$"
$k = "\\lorfile\download"
$l = "\\lorfile\drivers"
$m = "\\lorfile\kixtart"
$n = "\\lorfile\netlogon"
$o = "\\lorfile\z"
$s = "\\lorfile\shared"
$u = "\\lorfile\@userid"
$v = "\\lorfile\@primarygroup"
$w = "\\lorfile\departments"

Use f: $f
Use g: $g
Use h: $h
Use s: $s
Use u: $u
Use v: $v
Use w: $w

;****
;**** If you are a domain admin it also sets
;**** up a few more network drives
;****
:Domain_admins
If InGroup ("Domain admins")
Use i: $i
Use j: $j
Use k: $k
Use l: $l
Use m: $m
Use n: $n
Use o: $o
EndIf


;****
;**** Everyone in the Oslo office has access to
;**** these printers
;****
:Printers_for_OSLO
If InGroup ("l_gr_all")
AddPrinterConnection ("\\lorfile\admin")
AddPrinterConnection ("\\lorfile\colorlaser")
EndIf

;****
;**** One group for each printer (default printer)
;**** Each person can only be in one group so
;**** additional printers must be defined here
;****
:Printers_for_IKT
If InGroup ("p_gr_ikt")
AddPrinterConnection ("\\lorfile\ikt")
If SetDefaultPrinter ("\\lorfile\admin")=0
EndIf
EndIf

:Printers_for_OPS
If InGroup ("p_gr_ops1")
AddPrinterConnection ("\\lorfile\ops1")
If SetDefaultPrinter ("\\lorfile\ops1")=0
EndIf
EndIf

If InGroup ("p_gr_ops2")
AddPrinterConnection ("\\lorfile\ops2")
If SetDefaultPrinter ("\\lorfile\ops2")=0
EndIf
EndIf

If InGroup ("p_gr_ops3")
AddPrinterConnection ("\\lorfile\ops3")
If SetDefaultPrinter ("\\lorfile\ops3")=0
EndIf
EndIf

If InGroup ("p_gr_ops4")
AddPrinterConnection ("\\lorfile\ops4")
If SetDefaultPrinter ("\\lorfile\ops4")=0
EndIf
EndIf

:Printers_for_DRY
If InGroup ("p_gr_dry1")
AddPrinterConnection ("\\lorfile\dry1")
If SetDefaultPrinter ("\\lorfile\dry1")=0
EndIf
EndIf

If InGroup ("p_gr_dry2")
AddPrinterConnection ("\\lorfile\dry2")
If SetDefaultPrinter ("\\lorfile\dry2")=0
EndIf
EndIf

If InGroup ("p_gr_dry3")
AddPrinterConnection ("\\lorfile\dry3")
If SetDefaultPrinter ("\\lorfile\dry3")=0
EndIf
EndIf

If InGroup ("p_gr_dry4")
AddPrinterConnection ("\\lorfile\dry4")
If SetDefaultPrinter ("\\lorfile\dry4")=0
EndIf
EndIf

:Printers_for_SandP
If InGroup ("p_gr_sandp1")
AddPrinterConnection ("\\lorfile\sandp1")
If SetDefaultPrinter ("\\lorfile\sandp1")=0
EndIf
EndIf

If InGroup ("p_gr_sandp2")
AddPrinterConnection ("\\lorfile\sandp2")
If SetDefaultPrinter ("\\lorfile\sandp2")=0
EndIf
EndIf

:Printers_for_NBOff
If InGroup ("p_gr_nboff")
AddPrinterConnection ("\\lorfile\nboff")
If SetDefaultPrinter ("\\lorfile\nboff")=0
EndIf
EndIf

:Printers_for_TANK
If InGroup ("p_gr_tank")
AddPrinterConnection ("\\lorfile\tank")
If SetDefaultPrinter ("\\lorfile\tank")=0
EndIf
EndIf

:Printers_for_GAS
If InGroup ("p_gr_gas")
AddPrinterConnection ("\\lorfile\gas")
If SetDefaultPrinter ("\\lorfile\gas")=0
EndIf
EndIf

:Printers_for_ADMIN
If InGroup ("p_gr_admin2")
AddPrinterConnection ("\\lorfile\admin2")
If SetDefaultPrinter ("\\lorfile\admin2")=0
EndIf
EndIf

If InGroup ("p_gr_admin3")
AddPrinterConnection ("\\lorfile\admin3")
If SetDefaultPrinter ("\\lorfile\admin3")=0
EndIf
EndIf

:Printers_for_ACCOUNT
If InGroup ("p_gr_account")
AddPrinterConnection ("\\lorfile\account")
If SetDefaultPrinter ("\\lorfile\account")=0
EndIf
EndIf

:Printers_for_RESEARCH
If InGroup ("p_gr_research")
AddPrinterConnection ("\\lorfile\research")
If SetDefaultPrinter ("\\lorfile\research")=0
EndIf
EndIf

;****
;**** Copying necessary files for Symantec Live Update
;**** And setting necessary registry key
;****
Copy "%0\..\liveupdt.hst" "c:\program files\symantec\liveupdate\"
Copy "%0\..\s32luhl1.dll" "c:\program files\symantec\liveupdate\"
WriteValue("HKEY_LOCAL_MACHINE\SOFTWARE\Symantec\LiveUpdate\Preferences","All Transports Available","0","REG_DWORD")

;****
;**** Checking if screensaver is active
;**** If not, new screensaver is set
;****
$dir = ReadValue("HKEY_LOCAL_MACHINE\software\microsoft\windows NT\currentversion", "SystemRoot")
Copy "%0\..\ls.bmp" $dir
$scrsvr = $dir + "\ls.bmp"
WriteValue("HKEY_CURRENT_USER\Control Panel\Desktop","ScreenSaveActive","1","REG_SZ")
WriteValue("HKEY_CURRENT_USER\Control Panel\Desktop","ScreenSaveTimeOut","600","REG_SZ")
WriteValue("HKEY_CURRENT_USER\Control Panel\Desktop","SCRNSAVE.EXE",$dir + "\system32\ss3dfo.SCR","REG_SZ")
WriteValue("HKEY_CURRENT_USER\Control Panel\Screen Saver.3DFlyingObj","Texture",$scrsvr,"REG_SZ")
WriteValue("HKEY_CURRENT_USER\Control Panel\Screen Saver.3DFlyingObj","Size","100","REG_SZ")
WriteValue("HKEY_CURRENT_USER\Control Panel\Screen Saver.3DFlyingObj","Tesselation","200","REG_SZ")
WriteValue("HKEY_CURRENT_USER\Control Panel\Screen Saver.3DFlyingObj","Type","6","REG_SZ")

;****
;**** Checking if the homepage on IE is our official
;**** If not, http://www.lorstem.com is set
;****
:IE_Start_Page
$home=ReadValue("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main","Start Page")
If $home<>"http://www.lorstem.com"
Goto Set_Home_Page
Else
Goto end
EndIf
:Set_Home_Page
WriteValue("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main","Start Page","http://www.lorstem.com","REG_SZ")

;****
;**** Flushing all keystrokes
;****
flushkb

:END
Exit


Top
#29924 - 2002-09-29 05:32 PM Re: Copying files
Fernando Madruga Offline
Starting to like KiXtart

Registered: 2002-08-21
Posts: 149
Loc: Coimbra.Portugal.Europe.Earth....
Try creating a batch file (plain, old, batch file!) with a single COPY line to perform the same thing and assign that as the logon script. (Maybe with a net use before to set N:?)

Run it and let us know...
_________________________
Later,   [b]Mad[/b]ruga

Top
#29925 - 2002-09-29 05:43 PM Re: Copying files
Sverre Offline
Getting the hang of it

Registered: 2002-09-29
Posts: 52
Works like a dream, but it's kind of cheating. [Mad]

code:
 @echo off
copy %0\..\ls.bmp %windir% > null
kix32 login.kix



Top
#29926 - 2002-09-29 05:47 PM Re: Copying files
Fernando Madruga Offline
Starting to like KiXtart

Registered: 2002-08-21
Posts: 149
Loc: Coimbra.Portugal.Europe.Earth....
Sometimes, the best solutions are not the "pretiest" ones... Besides, now you have a working solution so you can shift your focus elsewhere. Someday, when you're less stressed, maybe it'll "hit" you and you'll get back to this.
Also, did you check LLigetfa's and Lonkero's sugestions about the "%0" ?
_________________________
Later,   [b]Mad[/b]ruga

Top
#29927 - 2002-09-29 05:50 PM Re: Copying files
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
I don't think you understand the %0\..% thingy.  Try the following two examples and maybe it'll enlighten.

First a batch file test.bat
code:
 echo %0\..% this is what you get in a batch file
kix32 test.txt
exit

Then a Kix script test.txt
code:
 break on
"%0\.." + ' <= This is what "%0\.." gives you in KiX' ?
"%0\..%" + ' <= This is what %"' + '0\..%" gives you in KiX' ?
ExpandEnvironmentVars("%0\..%") + ' <= This is what ExpandEnvironmentVars(%"' + '"0\..%) gives you in KiX' ?
"%0\..\ls.bmp" + ' <= This is what %"' + '0\..\ls.bmp" gives you in KiX' ?
get $



[ 29. September 2002, 17:50: Message edited by: LLigetfa ]
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#29928 - 2002-09-29 05:51 PM Re: Copying files
Sverre Offline
Getting the hang of it

Registered: 2002-09-29
Posts: 52
Didn't check the %0 since it works a few lines above.
Top
#29929 - 2002-09-29 06:08 PM Re: Copying files
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
So, do you understand why it supposedly works on one line and not the other?

I certainly would not use code that I don't understand. When you adopt code you don't understand, it has a way of turning and biting you.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#29930 - 2002-09-29 06:15 PM Re: Copying files
Sverre Offline
Getting the hang of it

Registered: 2002-09-29
Posts: 52
Well, I wouldn't say I don't understand it. On the other hand, most of us don't know what most functions we use in programming really does. I mean, we understand what it returns, but do we understand exactly what it does to bring us the result? I haven't programmed in assembler since my days at college and that was in the late 70s heheh.

What I asked the scrit to do in this case was to copy a file from the netlogon folder of the "active" domain controller and put it in the directory where the operating system was installed. Not sure if anyone can ask me to understand more than that. [Wink]

Top
#29931 - 2002-09-29 06:51 PM Re: Copying files
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
netlogon...

so @ldrive+"\file" is the actual...

anyway, what comes to assembler, it's hard way to go as there is no api's in assembler and don't know if even ruud understands fully what is behind all of those...

anyway, withing kixtart yoou can't see the %1 and so forth and I don't think that you can see %0 either.

so, my quess is that you use it in shell/run call. and then it works.
but directly in kix it shouldn't.

what is the command before where it works?

{edit}
checked on that...
are you sure it works? as it might be there already...
 

[ 29. September 2002, 18:53: Message edited by: Lonkero ]
_________________________
!

download KiXnet

Top
#29932 - 2002-09-29 07:05 PM Re: Copying files
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Well, I'll be the first to admit that I don't understand how (why?) it works further up in the script. Don't understand the connection to assembler either... particularly since KiX isn't written in assembly. What comes to assembly, at least there, every line is fully understandable. With APIs, there's a lot hidden under the covers.

My memory of assember is more recent (early 80s) but still does not enlighten.

The reason I say it may turn and bite is that XP has changed the behaviour of %0.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#29933 - 2002-09-29 07:14 PM Re: Copying files
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
I have a dream.

I dream of ability to create a kix-compiler but don't which way to go...
quess the assembler anyway isn't the way to go.

well, I'll keep the dream alive and maybe at some point it will come true.
 
_________________________
!

download KiXnet

Top
#29934 - 2002-09-29 10:46 PM Re: Copying files
kholm Offline
Korg Regular
*****

Registered: 2000-06-19
Posts: 714
Loc: Randers, Denmark
You want to copy from the NetLonon share, to a local file !

There has been some issues on the "%0\..\" on WinXP posted on this board.
Furthermore, %0 is a batchfile parameter, you can replace this in a KiX-script.

Instead of this:
Copy "%0\..\ls.bmp" $dir

Try using:
Copy "@LServer\Netlogon\ls.bmp" $dir

-Erik

Top
#29935 - 2002-09-29 10:58 PM Re: Copying files
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
erik, isn't:
Copy "@LServer\Netlogon\ls.bmp" $dir

just the same as:
Copy "@ldrive\ls.bmp" $dir
_________________________
!

download KiXnet

Top
#29936 - 2002-09-30 05:42 PM Re: Copying files
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
You need to have administrative rights in order to copy files into most of the WINNT (sub-)directories. Also, I would alwasy specify the complete file for both he copy-from and the copy-to and do an EXIST beforehand to make sure the file actually exists.Thus:
code:
$copyfrom='\\server\share\fiel.txt'
$copyto='%WINNT%'
if exist($copyfrom)
if exist($copyto)
copy $copyfrom $copyto
if @ERROR
? 'Error copying file: '+@ERROR+' - '+@SERROR
endif
else
? 'Cannot find folder '+$copyto
endif
else
? 'Cannot find file '+$copyfrom
endif

I know it it some mmore code to just copy a file but it'll help tremendously in troubleshooting if it doesn't work.
_________________________
There are two types of vessels, submarines and targets.

Top
Page 2 of 2 <12


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

Who's Online
1 registered (Allen) and 1198 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.074 seconds in which 0.035 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