#135102 - 2005-03-09 01:27 AM
help with the code
|
ozraelised
Getting the hang of it
Registered: 2002-12-02
Posts: 59
Loc: Albury
|
Hi,
CAn someone help me with the code. This code was suggested to me by NTDOC and Howard Bullock so the level of KiXtart is way way to high for me.The idea is to desplay meesags on the screen using logon scripts every 45 days. I have windows 2000 server and clients running on windows XP SP1 and Windows 2000 SP3. Thank you all in advance 
Code:
Dim $OS, $Msg, $Answer, $RC
$OS=setOption('Explicit','off') $OS=setOption('NoVarsInString','On') $OS=setOption('WrapAtEOL','On')
Dim $SetCounter, $Key, $KeyValue, $Delay,$KiXtartSchedule $Delay=3888000 $SetCounter=FileTime(@Date,@Time) $KiXtartSchedule="HKEY_CURRENT_USER\Software\LogOnScripts\Schedule\45" $Key=KeyExist($KiXtartSchedule)
If $Key $KeyValue=Val(ReadValue($KiXtartScheduale,'time')) If SetCounter > ($KeyValue+$Delay) $Answer=MessageBox("what ever need to be said","Reminder",4180) If $Answer <>6 $Msg=MessageBox("what ever need to be said",4112) $RC=LogOff(1) Else $Msg=MessageBox(What ever need to be said",64,5) EndIf KeyValue=WriteValue$KiXtartSchedule,'time',$SetCounter,REG_SZ) If $Answer <>6 $Msg=MessageBox("what ever need to be said",4112) $RC=LogOff(1) Else $Msg=MessageBox(What ever need to be said",64,5) EndIf Endif If InGroup("Domain Users") MapDrive("F:", "jmmes", "Vol1") MapDrive("G:", "jmmes", "mCalas") MapDrive("H:", "jmmes", "caldata") MapDrive("I:", "jmmes", "s6system") MapDrive("J:", "jmmes", "winapp") ; K: Drive Mapped by OS as Home Share MapDrive("L:", "j :Jmmes", "abas") MapDrive("M:", "jmmes", "vol1") MapDrive("N:", "jmmes", "netapps") MapDrive("O:", "jmmes", "JMME-FPlan") MapDrive("P:", "jmmes", "apps") MapDrive("Q:", "jmmes" ,"NotesMME") MapDrive("S:", "jmmes", "vol2") MapDrive("T:", "jmmes", "templates") MapDrive("Y:", "jmmes", "PWCDll") Endif
Function MapDrive($Drive, $Server, $Share) Dim $Drive, $Server, $Share, $shell Color c+/n
If $Drive<>"" and $Server<>"" and $Share<>"" $LogText="Connecting $Drive to \\$Server\$Share" ? $LogText USE $Drive /Delete /Persistent USE $Drive "\\" + $Server + "\" + $Share If @error=0 color g+/n $x = " - Success" $x If val($DOS) >= 5 $shell=createobject("shell.application") $shell.namespace($Drive+"\").self.name=$Share + " on '" + $Server + "'" $shell = 0 Endif Else color r+/n $x = " - Failed: Error " + @error $x $ErrorState=1 Endif ; Commented out logging ;WriteLog ($LogText + $x) ;WriteLog2("%temp%\MapDrive.log",$LogText + $x,1) Color w+/n Else ? "Function 'MapDrive' called with invalid parameters: '$Drive', '$Server', '$Share'" ; Commented out logging ;WriteLog ("Function 'MapDrive' called with invalid parameters: '$Drive', '$Server', '$Share'") Endif Endfunction
Else keyValue=WriteValue$KiXtartSchedule,'time',SetCounter,REG_SZ)
Function FlipcTime($date,$time,optional $tz) Dim $y,$m,$d
$date = split($date,"/")
If ubound($date) <> 2 exit(1) Endif
$y=val($date[0]) $m=val($date[1]) $d=val($date[2]) If $m<3 $m=$m+12 $y=$y-1 Endif
$Date=$d+(153*$m-457)/5+365*$y+$y/4-$y/100+$y/400-306 $time = split($time,":")
Select case ubound($time)=1 redim preserve $time[2] $time[2]=0 case ubound($time)=2 case 1 exit(1) Endselect
$time = (val($time[0])*3600)+(val($time[1])*60)+val($time[2]) flipctime=IIF($tz,(($date-719163)*86400+$time)-($tz*3600),($date-719163)*86400 + $time) endfunction
|
|
Top
|
|
|
|
#135106 - 2005-03-09 04:09 AM
Re: help with the code
|
ozraelised
Getting the hang of it
Registered: 2002-12-02
Posts: 59
Loc: Albury
|
Hi Jose,
Ok; thanks for that - I am going to have a go.I will let you know how did I go.
Again thank you for your help
|
|
Top
|
|
|
|
#135107 - 2005-03-09 06:14 AM
Re: help with the code
|
ozraelised
Getting the hang of it
Registered: 2002-12-02
Posts: 59
Loc: Albury
|
Hi Jose,
I am in a bit of a situation. the script is working but then I am unable to get my mapdrives, or the other way I get my mapdrives but the messagebox will not work.
I have a batch file that call the scripts for the server but for some reasons it will only call the first script on the list. Also if I combinde the two scripts into one it will only do one thing and that is depending on which of the codes is on the top of the page. HAve you got any idea on how I can add an extra script to NTDOC script.
Again thank you for your help
|
|
Top
|
|
|
|
#135108 - 2005-03-09 08:30 AM
Re: help with the code
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11631
Loc: CA
|
Okay Oz... not sure but I think this is closer to what you're wanting it to do. If the Key does not exist it will create it and display the message box for the first time and won't display it again for 45 days. If the user does not click on OK it will log him/her off. If they click OK it will continue on to the DriveMap checking routine.
I HAVE NOT TESTED THIS - IT IS ONLY PROOF OF CONCEPT CODE
Break Off Dim $SO,$Pause $SO=SetOption('Explicit','On') $SO=SetOption('NoVarsInStrings','On') $SO=SetOption('WrapAtEOL','On') Dim $SetCounter,$Key,$KeyValue,$Delay,$RC,$Answer,$Msg $Delay=3888000 $SetCounter=FlipcTime(@DATE,@TIME) $Key=KeyExist('HKCU\Software\LogOnScripts\Schedule\45') If $Key $KeyValue=Val(ReadValue('HKCU\Software\LogOnScripts\Schedule\45','time')) If $SetCounter > ($KeyValue+$Delay) ; Reset the counter to current time so you can check properly next time $KeyValue=WriteValue('HKCU\Software\LogOnScripts\Schedule\45','time',$SetCounter,REG_SZ) $Answer=MessageBox('You must agree that Ozz is the man or you will be logged off','Reminder',4164) If $Answer=7 $Msg=MessageBox('Since you chose NO you must be logged off now','Goodbye now 1st',4144) $RC=LogOff(1) Else $Msg=MessageBox('Thank you for agreeing with me. You may continue now..1st.','Ozz is the man',4160,5) EndIf EndIf Else $KeyValue=WriteValue('HKCU\Software\LogOnScripts\Schedule\45','time',$SetCounter,REG_SZ) $Answer=MessageBox('You must agree that Ozz is the man or you will be logged off 2nd','Reminder',4164) If $Answer=7 $Msg=MessageBox('Since you chose NO you must be logged off now','Goodbye now 2nd',4144) $RC=LogOff(1) Else $Msg=MessageBox('Thank you for agreeing with me. You may continue now..2nd.','Ozz is the man',4160) EndIf Endif If InGroup('Domain Users') MapDrive('F:', 'jmmes', 'Vol1') MapDrive('G:', 'jmmes', 'mCalas') MapDrive('H:', 'jmmes', 'caldata') MapDrive('I:', 'jmmes', 's6system') MapDrive('J:', 'jmmes', 'winapp') ; K: Drive Mapped by OS as Home Share MapDrive('L:', 'j :Jmmes', 'abas') MapDrive('M:', 'jmmes', 'vol1') MapDrive('N:', 'jmmes', 'netapps') MapDrive('O:', 'jmmes', 'JMME-FPlan') MapDrive('P:', 'jmmes', 'apps') MapDrive('Q:', 'jmmes' ,'NotesMME') MapDrive('S:', 'jmmes', 'vol2') MapDrive('T:', 'jmmes', 'templates') MapDrive('Y:', 'jmmes', 'PWCDll') Endif Quit 1 Function FlipcTime($date,$time,optional $tz) Dim $y,$m,$d $date = Split($date,"/") If UBound($date) <> 2 Exit(1) EndIf $y=Val($date[0]) $m=Val($date[1]) $d=Val($date[2]) If $m<3 $m=$m+12 $y=$y-1 EndIf $Date=$d+(153*$m-457)/5+365*$y+$y/4-$y/100+$y/400-306 $time = Split($time,":") Select Case UBound($time)=1 ReDim PreServe $time[2] $time[2]=0 Case UBound($time)=2 Case 1 Exit(1) EndSelect $time = (Val($time[0])*3600)+(Val($time[1])*60)+Val($time[2]) $flipctime = IIF($tz,(($date-719163)*86400 + $time)-($tz*3600),($date-719163)*86400 + $time) EndFunction Function MapDrive($Drive, $Server, $Share) Dim $Drive, $Server, $Share, $shell Color c+/n If $Drive<>"" And $Server<>"" And $Share<>"" $LogText="Connecting " + $Drive + " to \\" + $Server + "\" + $Share ? $LogText USE $Drive /Delete /Persistent USE $Drive "\\"+$Server+"\"+$Share If @ERROR=0 Color g+/n $x=" - Success" $x If Val($DOS) >= 5 $shell=CreateObject("shell.application") $shell.NameSpace($Drive+"\").Self.Name=$Share + " on '" + $Server + "'" $shell = 0 EndIf Else Color r+/n $x=" - Failed: Error " + @ERROR $x $ErrorState=1 EndIf Color w+/n Else Endif Endfunction
|
|
|
Top
|
|
|
|
#135109 - 2005-03-09 09:18 AM
Re: help with the code
|
ozraelised
Getting the hang of it
Registered: 2002-12-02
Posts: 59
Loc: Albury
|
HI NTDOC,
Again thank you for all your help, I am going to test the script. I just want to let all you guys to know that I also try and undersdand the script not just copy it. I have time issues and users that are a pain in the backside. So thank you for your time and understanding I think you guys doing an excellet job.
|
|
Top
|
|
|
|
#135110 - 2005-03-09 09:31 AM
Re: help with the code
|
ozraelised
Getting the hang of it
Registered: 2002-12-02
Posts: 59
Loc: Albury
|
HI NTDOC,
I runnthe script and I get the error: ERROR : expected expression! Script: C:\KiXtart\finalscript.KIX Line : 9
Now I looked at the other scripts and it is the same. At this point I am not sure why or what is causing the error. Please see if you can understand why the error is coming up?
Thanks 
|
|
Top
|
|
|
|
#135112 - 2005-03-09 11:42 AM
Re: help with the code
|
ozraelised
Getting the hang of it
Registered: 2002-12-02
Posts: 59
Loc: Albury
|
HI NTDOC,
I use version 4.22 . I did as you suggeted and got a diff' erro on line 79:
ERROR : duplicated definition of variable [$Drive] Script: c:\KiXtart\Logonscript.KIX Line : 79
I am going to print yu script and type in again and see what is the go. Again I would like to thank you for taking the time with me.
Thanks
|
|
Top
|
|
|
|
#135113 - 2005-03-09 03:17 PM
Re: help with the code
|
Kdyer
KiX Supporter
   
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
In your code, where you have: Code:
Function MapDrive($Drive, $Server, $Share) Dim $Drive, $Server, $Share, $shell
You need to change it to: Code:
Function MapDrive($Drive, $Server, $Share) Dim $Server, $Share, $shell
The problem is that the Function uses $Drive as a variable being passed to the Function and it does not need to be re-dimmed.
HTH,
Kent
|
|
Top
|
|
|
|
#135115 - 2005-03-09 11:43 PM
Re: help with the code
|
ozraelised
Getting the hang of it
Registered: 2002-12-02
Posts: 59
Loc: Albury
|
HI NTDOC,
Thanks for the information I am going to have a look. I am not sure if it will help but at present I am running this script just on two machines for testing one is XP the other is win 2000.
The code for the DriveMap seems to be the same as the one you have and it is working fine. So I am in a state of confussion. I am goiong to do a search to find all KIX32 files on my server, do you think that the version in the NETLOGON can be diff'. is there away to unregister KIX32? What is the best way to confirm what verion of KIX32 I am using to run the scripts? At the moment I take it is the KIX32 that is in the same folder that the scripts are stored in. I point to this folder when I am going to DOS.
Again thank you and all the other guys 
Code:
Dim $0S, $Msg, $Answer, $RC $OS=SetOption('Explicit','off') $OS=SetOption('NoVarsInStrings','On') $OS=SetOption('WrapAtEOL','On')
$Answer = MessageBox ("Please confirm that you have read and understood the firm's IT policy. If you have any questions relative to this please contact Gary or Rae", "Reminder", 4180) If $Answer <> 6 $Msg=MessageBox ( "You are unable to log to the network", "call your IT Administrator", 4112) $RC=Logoff(1) Else ;$ = shutdown("","you are being logged off",45,1,1) $Msg=MessageBox ("You are now being connected to the network","Welcome to Johnsons MME",64,5) Endif
If InGroup("Domain Users") MapDrive("F:", "jmmes", "Vol1") MapDrive("G:", "jmmes", "mCalas") MapDrive("H:", "jmmes", "caldata") MapDrive("I:", "jmmes", "s6system") MapDrive("J:", "jmmes", "winapp") ; K: Drive Mapped by OS as Home Share MapDrive("L:", "jmmes", "abas") MapDrive("M:", "jmmes", "vol1") MapDrive("N:", "jmmes", "netapps") MapDrive("O:", "jmmes", "JMME-FPlan") MapDrive("P:", "jmmes", "apps") MapDrive("Q:", "jmmes" ,"NotesMME") MapDrive("S:", "jmmes", "vol2") MapDrive("T:", "jmmes", "templates") MapDrive("Y:", "jmmes", "PWCDll") Endif
Function MapDrive($Drive, $Server, $Share) Dim $Drive, $Server, $Share, $shell Color c+/n
If $Drive<>"" and $Server<>"" and $Share<>"" $LogText="Connecting $Drive to \\$Server\$Share" ? $LogText USE $Drive /Delete /Persistent USE $Drive "\\" + $Server + "\" + $Share If @error=0 color g+/n $x = " - Success" $x If val($DOS) >= 5 $shell=createobject("shell.application") $shell.namespace($Drive+"\").self.name=$Share + " on '" + $Server + "'" $shell = 0 Endif Else color r+/n $x = " - Failed: Error " + @error $x $ErrorState=1 Endif ; Commented out logging ;WriteLog ($LogText + $x) ;WriteLog2("%temp%\MapDrive.log",$LogText + $x,1) Color w+/n Else ? "Function 'MapDrive' called with invalid parameters: '$Drive', '$Server', '$Share'" ; Commented out logging ;WriteLog ("Function 'MapDrive' called with invalid parameters: '$Drive', '$Server', '$Share'") Endif Endfunction
|
|
Top
|
|
|
|
#135117 - 2005-03-10 05:19 AM
Re: help with the code
|
ozraelised
Getting the hang of it
Registered: 2002-12-02
Posts: 59
Loc: Albury
|
Hi NTDOC,
Ok Ok Ok it is working  I removed the veriable and add the one that needed and it is working.
This is funtastic. Thank you very much for the help and the time and the energy you took into helping me. And again not just me and alot of other people will get a good script, but alot of us will learn form that.
So thank you This is the code as it worked on my machince. I removed the words from the MessageBox. Again thank you very much.
Code:
Break Off Dim $SO, $Pause $SO=SetOption('Explicit','off') $SO=SetOption('NoVarsInStrings','On') $SO=SetOption('WrapAtEOL','On')
Dim $SetCounter, $Key, $KeyValue, $Delay, $RC, $Answer, $Msg $Delay=3888000 $SetCounter=FlipcTime(@DATE,@TIME) $Key=KeyExist('HKCU\Software\LogOnScripts\Schedule\45') If $Key $KeyValue=Val(ReadValue('HKCU\Software\LogOnScripts\Schedule\45','time')) If $SetCounter > ($KeyValue+$Delay) ; Reset the counter to current time so you can check properly next time $KeyValue=WriteValue('HKCU\Software\LogOnScripts\Schedule\45','time',$SetCounter,REG_SZ) $Answer=MessageBox('what ever','Reminder',4164) If $Answer=7 $Msg=MessageBox('What ever',4144) $RC=LogOff(1) Else $Msg=MessageBox('what ever',4160,5) EndIf EndIf Else $KeyValue=WriteValue('HKCU\Software\LogOnScripts\Schedule\45','time',$SetCounter,REG_SZ) $Answer=MessageBox('what ever','Reminder',4164) If $Answer=7 $Msg=MessageBox('what ever',4144) $RC=LogOff(1) Else $Msg=MessageBox('what ever',4160) EndIf Endif
If InGroup ('Domain Users') MapDrive ('R:', 'jmmes', 'Vol1') MapDrive ('G:', 'jmmes', 'mCalas') MapDrive ('H:', 'jmmes', 'caldata') MapDrive ('I:', 'jmmes', 's6system') MapDrive ('J:', 'jmmes', 'winapp') ; K: Drive Mapped by OS as Home Share MapDrive ('L:', 'jmmes', 'abas') MapDrive ('M:', 'jmmes', 'vol1') MapDrive ('N:', 'jmmes', 'netapps') MapDrive ('O:', 'jmmes', 'JMME-FPlan') MapDrive ('P:', 'jmmes', 'apps') MapDrive ('Q:', 'jmmes', 'NotesMME') MapDrive ('S:', 'jmmes', 'vol2') MapDrive ('T:', 'jmmes', 'templates') MapDrive ('Y:', 'jmmes', 'PWCDll') Endif
Quit 1
Function FlipcTime($date,$time,optional $tz) Dim $y,$m,$d $date = Split($date,"/") If UBound($date) <> 2 Exit(1) EndIf $y=Val($date[0]) $m=Val($date[1]) $d=Val($date[2]) If $m<3 $m=$m+12 $y=$y-1 EndIf $Date=$d+(153*$m-457)/5+365*$y+$y/4-$y/100+$y/400-306 $time = Split($time,":") Select Case UBound($time)=1 ReDim PreServe $time[2] $time[2]=0 Case UBound($time)=2 Case 1 Exit(1) EndSelect $time = (Val($time[0])*3600)+(Val($time[1])*60)+Val($time[2]) $flipctime = IIF($tz,(($date-719163)*86400 + $time)-($tz*3600),($date-719163)*86400 + $time) EndFunction
Function MapDrive($Drive,$Server,$Share) Dim $LogText, $x, $ErrorState, $Dos, $Shell Color c+/n If $Drive<>"" And $Server<>"" And $Share<>"" $LogText="Connecting " + $Drive + " to \\" + $Server + "\" + $Share ? $LogText USE $Drive /Delete /Persistent USE $Drive "\\"+$Server+"\"+$Share If @ERROR=0 Color g+/n $x=" - Success" $x If Val($DOS) >= 5 $shell=CreateObject("shell.application") $shell.NameSpace($Drive+"\").Self.Name=$Share + " on '" + $Server + "'" $shell = 0 EndIf Else Color r+/n $x=" - Failed: Error " + @ERROR $x $ErrorState=1 EndIf Color w+/n Else Endif Endfunction
|
|
Top
|
|
|
|
#135118 - 2005-04-22 01:09 PM
Re: help with the code
|
jechilt
Starting to like KiXtart
Registered: 2000-12-01
Posts: 102
Loc: Denver Colorado
|
I know this thread is a little old but can somebody tell me what the $DOS variable is supposed to be doing? I see that it is declared and then being used as an input variable for VAL, but that appears to be it....makes no sense to me.
_________________________
John LM Contractor One of the 2 dads
|
|
Top
|
|
|
|
#135121 - 2005-04-26 01:54 AM
Re: help with the code
|
ozraelised
Getting the hang of it
Registered: 2002-12-02
Posts: 59
Loc: Albury
|
Hi Guys
45 days gone since I run the Script and this morning I got it again. Excellent. The only problem is that the mapdrive didn't come up only the K drive and the Z drive. The K drive is mapped from the user profile, I don't understand why a script that worked before and with no changes will not work. this is the code: Break Off Dim $SO, $Pause $SO=SetOption('Explicit','On') $SO=SetOption('NoVarsInStrings','On') $SO=SetOption('WrapAtEOL','On')
Dim $SetCounter, $Key, $KeyValue, $Delay, $RC, $Answer, $Msg $Delay=3888000 $SetCounter=FlipcTime(@DATE,@TIME) $Key=KeyExist('HKCU\Software\LogOnScripts\Schedule\45') If $Key $KeyValue=Val(ReadValue('HKCU\Software\LogOnScripts\Schedule\45','time')) If $SetCounter > ($KeyValue+$Delay) ; Reset the counter to current time so you can check properly next time $KeyValue=WriteValue('HKCU\Software\LogOnScripts\Schedule\45','time',$SetCounter,REG_SZ) $Answer=MessageBox('You must agree that Ozz is the man or you will be logged off','Reminder',4164) If $Answer=7 $Msg=MessageBox('Since you chose NO you must be logged off now','Goodbye now 1st',4144) $RC=LogOff(1) Else $Msg=MessageBox('Thank you for agreeing with me. You may continue now..1st.','Ozz is the man',4160,5) EndIf EndIf Else $KeyValue=WriteValue('HKCU\Software\LogOnScripts\Schedule\45','time',$SetCounter,REG_SZ) $Answer=MessageBox('You must agree that Ozz is the man or you will be logged off 2nd','Reminder',4164) If $Answer=7 $Msg=MessageBox('Since you chose NO you must be logged off now','Goodbye now 2nd',4144) $RC=LogOff(1) Else $Msg=MessageBox('Thank you for agreeing with me. You may continue now..2nd.','Ozz is the man',4160) EndIf Endif
If InGroup ('Domain Users') MapDrive ('F:','jmmes', 'Vol1') MapDrive ('G:', 'jmmes', 'mCalas') MapDrive ('H:', 'jmmes', 'caldata') MapDrive ('I:', 'jmmes', 's6system') MapDrive ('J:', 'jmmes', 'winapp') ; K: Drive Mapped by OS as Home Share MapDrive ('L:', 'jmmes', 'abas') MapDrive ('M:', 'jmmes', 'vol1') MapDrive ('N:', 'jmmes', 'netapps') MapDrive ('O:', 'jmmes', 'JMME-FPlan') MapDrive ('P:', 'jmmes', 'apps') MapDrive ('Q:', 'jmmes', 'NotesMME') MapDrive ('S:', 'jmmes', 'vol2') MapDrive ('T:', 'jmmes', 'templates') MapDrive ('Y:', 'jmmes', 'PWCDll') Endif
Quit 1
Function FlipcTime($date,$time,optional $tz) Dim $y,$m,$d $date = Split($date,"/") If UBound($date) <> 2 Exit(1) EndIf $y=Val($date[0]) $m=Val($date[1]) $d=Val($date[2]) If $m<3 $m=$m+12 $y=$y-1 EndIf $Date=$d+(153*$m-457)/5+365*$y+$y/4-$y/100+$y/400-306 $time = Split($time,":") Select Case UBound($time)=1 ReDim PreServe $time[2] $time[2]=0 Case UBound($time)=2 Case 1 Exit(1) EndSelect $time = (Val($time[0])*3600)+(Val($time[1])*60)+Val($time[2]) $flipctime = IIF($tz,(($date-719163)*86400 + $time)-($tz*3600),($date-719163)*86400 + $time) EndFunction
Function MapDrive($Drive,$Server,$Share) Dim $Drive, $Server, $Share, $Shell Color c+/n If $Drive<>"" And $Server<>"" And $Share<>"" $LogText="Connecting " + $Drive + " to \\" + $Server + "\" + $Share ? $LogText USE $Drive /Delete /Persistent USE $Drive "\\"+$Server+"\"+$Share If @ERROR=0 Color g+/n $x=" - Success" $x If Val($DOS) >= 5 $shell=CreateObject("shell.application") $shell.NameSpace($Drive+"\").Self.Name=$Share + " on '" + $Server + "'" $shell = 0 EndIf Else Color r+/n $x=" - Failed: Error " + @ERROR $x $ErrorState=1 EndIf Color w+/n Else Endif Endfunction
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 567 anonymous users online.
|
|
|