Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 754
  • Last Modified:

Login script problem

Over the past few weeks my old login script has been acting funny. This login script was written by a former employee and seems to have issues on occasions, so I'd like a new script. I'm not very familiar with writing scripts and any help would be appreciated.
The script is initialized with login.bat, which calls login.kix for added functionality. The login.bat is written as a batch file, the login.kix is written in Kixtart. I'd just like to clean this up and make it run more efficent. All help is appreciated.

I'm including the old script for those who might can help.

login.bat part:

net use H: /del
net use G: /DEL
net use P: /del
REM net use M: /del
net use W: /del

ipconfig /flushdns

gpupdate

w32tm /resync

net use W: \\***-DC02\%username%$

%0\..\Kix32.exe \\***.net\NETLOGON\login.KIX

%0\..\Kix32.exe \\***.net\NETLOGON\productID.kix

net localgroup administrators local_admins_sec /add

\\***-dc02\netlogon\IE20Blocker.cmd /B

REM at 00:00 cmd \\***-dc02\netlogon\sysnfo.bat

REM \\***-dc02\netlogon\***news.vbs

\\***-dc02\netlogon\audit.bat
:end


Kixtart  part:

If InGroup("Presidents_Sec")
 ?Executive Private Access Granted
   USE G: "\\fileserver\executiveprivate$" /PERSISTENT
   USE H: "\\fileserver\***$" /PERSISTENT
   USE P: "\\fileserver\public" /PERSISTENT
EndIF

IF InGroup("***_Sec")
  ?BFA Access Granted
   USE G:  "\\fileserver\***$" /PERSISTENT
   USE P:  "\\fileserver\public" /PERSISTENT
ENDIF
      
IF InGroup("SBS_Sec")
      ? "Your access to file shares is currenly limited"
ENDIF

IF InGroup("Domain_Admins_Sec")
 ?Domain Admin Access Granted
  USE H: "\\fileserver\***$" /PERSISTENT
  USE M: "\\fileserver\MIS$" /PERSISTENT
  USE P: "\\fileserver\public" /PERSISTENT
ENDIF

If ADDPRINTERCONNECTION ("\\***-dc2\Dell Laser Printer 5100cn PCL6") = 0
      ? "Added Printer Connection... Dell Laser Printer"
ENDIF

If ADDPRINTERCONNECTION ("\\***-dc2\CanoniR 2800") = 0
      ? "Added Printer Connection... Canon Printer"
EndIF

If ADDPRINTERCONNECTION ("\\***-dc2\Canon iR 2200-3300(FAX)") = 0
      ? "Added Fax Machine connection... Canon Fax Machine"
EndIF
0
jeania
Asked:
jeania
1 Solution
 
Bill BachPresidentCommented:
It might be helpful to know which part has problems, and what kind of problems it has.  "Fixing" the script is difficult if we don't know what is wrong with it.

Also, there is a second Kix script being called (productID.kix) that you didn't include, as well as a command script (IE20Blocker.cmd) and a batch file (audit.bat).  The other batch file (sysnfo.bat) and VBScript file (news.vbs) are currently commented out, and can be ignored, or at least removed from the login.bat file.
0
 
jeaniaAuthor Commented:
The biggest problem is with the network drives being mapped correctly. If I don't need all the script I'd like to make it simple. I'm including the other you mentioned.


productID.kix:
Break On
Dim $SO
$SO=SetOption('Explicit','On')
$SO=SetOption('NoVarsInStrings','On')

Dim $RegArray,$Value,$Product,$Key
$RegArray = SearchReg("HKLM\Software\Microsoft","DigitalProductID",2)
If @Error
'No matching items found' ?
Else
  For Each $Value In $RegArray
    If $Value
      $Product = ReadValue(Join(Split($value,'<=>DigitalProductId'),''),'ProductName')
      If $Product
        $Key = Get_Product_Key(ReadValue(Join(Split($value,'<=>DigitalProductId'),''), 'DigitalProductID'))
        $Product + ': ' + $Key ?
      EndIf
    EndIf
  Next
EndIf
 
Function SearchReg($Key,$Str,$SrcIn)
  Dim $Idx,$vName,$Value,$num,$SubKey,$fArr,$mbr
  $SearchReg = ''
  $num = 0
  $Idx = 0
  $vName = EnumValue($Key,$Idx)
  Do
    $mbr = ''
    If $SrcIn & 1
    $Value = ReadValue($Key,$vName)
     If InStr($Value,$Str)
       $mbr = $Key + "<=>" + IIf($vName,$vName,'')
     EndIf
    EndIf
    If ($SrcIn & 2) And InStr($vName,$Str)
      $mbr = $Key + "<=>" + $vName
    EndIf
    If $mbr
      ReDim Preserve $SearchReg[$num]
      $SearchReg[$num] = $mbr
      $num = $num + 1
    EndIf
    $Idx = $Idx + 1
    $vName = EnumValue($Key,$Idx)
  Until @Error
  $Idx = 0
  $SubKey = EnumKey($Key,$Idx)
  While $SubKey
    If ($SrcIn & 4) And InStr($SubKey,$Str)
      ReDim Preserve $SearchReg[$num]
      $SearchReg[$num] = $Key + '\' + $SubKey + "<=>"
      $num = $num + 1
    EndIf
    $fArr = SearchReg($Key + "\" + $SubKey,$Str,$SrcIn)
    If @Error = 0
      For Each $mbr In $fArr
        ReDim Preserve $SearchReg[$num]
        $SearchReg[$num] = $mbr
        $num = $num + 1
      Next
    EndIf
    $Idx = $Idx + 1
    $SubKey = EnumKey($Key,$Idx)
  Loop
  Exit VarType($SearchReg) = 8
EndFunction
 
Function Get_Product_Key($sProductID)
  Dim $aiKeyChars[24],$bProductKey[15],$ilByte,$i,$sCDKey,$nCur
  $aiKeyChars = Split('B,C,D,F,G,H,J,K,M,P,Q,R,T,V,W,X,Y,2,3,4,6,7,8,9',',')
  For $i = 0 To 14
    $bProductKey[$i] = Val("&"+SubStr($sProductID,$i*2+105,2))
  Next
  $sCDKey = ""
  For $ilByte = 24 To 0 Step -1
    $nCur = 0
    For $i=14 To 0 Step -1
      $nCur = $nCur * 256 | $bProductKey[$i]
      $bProductKey[$i] = Int($nCur / 24)
      $nCur = $nCur Mod 24
    Next
    $sCDKey = $aiKeyChars[$nCur] + $sCDKey
    If $ilByte Mod 5 = 0 And $ilByte <> 0 $sCDKey = "-" + $sCDKey EndIf
  Next
  $Get_Product_Key = $sCDKey
EndFunction


IE7Blocker.cmd:

@echo off

Echo MICROSOFT TOOL KIT TO DISABLE DELIVERY OF
Echo MICROSOFT INTERNET EXPLORER 7
Echo.
Echo Copyright (C) Microsoft Corporation.  All rights reserved.
Echo.

set ProductName=Internet Explorer 7.0
set REGBlockKey=HKLM\SOFTWARE\Microsoft\Internet Explorer\Setup\7.0
set REGBlockValue=DoNotAllowIE70

set RemoteMachine=%1

if ""=="%1" goto Usage
if "/?"=="%1" goto Usage
if /I "/H"=="%1" goto Usage
if /I "/B"=="%1" goto LocalMachine
if /I "/U"=="%1" goto LocalMachine
set RemoteMachineName=%1
set Action=%2

:Parse
if /I "/B" == "%Action%" goto Block
if /I "/U" == "%Action%" goto UnBlock
goto Usage

:Block
Echo Blocking deployment of %ProductName% on %RemoteMachineName%
REG ADD "\\%RemoteMachine%\%REGBlockKey%" /v %REGBlockValue% /t REG_DWORD /d 1 /f
goto End

:UnBlock
Echo Unblocking deployment of %ProductName% on %RemoteMachineName%
REG DELETE "\\%RemoteMachine%\%REGBlockKey%" /v %REGBlockValue% /f
goto End

:LocalMachine
set Action=%1
set RemoteMachine=.
set RemoteMachineName=the local machine
goto Parse

:Usage
Echo.
Echo This tool can be used to remotely block or unblock the delivery of
Echo %ProductName% via Automatic Updates.
Echo.
Echo ------------------------------------------------------------
Echo Usage:
Echo %0 [machine name] [/B] [/U] [/H]
REM [machine name] [/B|U|H]
Echo B = Block %ProductName% deployment
Echo U = Allow %ProductName% deployment
Echo H = Help
Echo.
Echo To block or unblock installation on the local machine use
Echo period ("." with no quotes) as the machine name
Echo.
Echo Examples:
Echo %0 mymachine /B (blocks delivery on machine "mymachine")
Echo.
Echo %0 /U (unblocks delivery on the local machine)
Echo ------------------------------------------------------------
Echo.

:End

audit.bat::

IF"%date:0,3%"=="Mon"\\***-dc02\software$\WinAudit.exe /r=gsoPxuTUeERNtnzDaIbMpmidcSArBLF /o=CSV /f=\\bfa-dc02\software$\audits /m=Network audit in progress, please be patient.
ENDIF

sysnfo.bat:

cd ..
cd ..
cd ..
cd ..
cd ..


cd Program Files

cd Common Files

cd Microsoft Shared

cd MSInfo

msinfo32 /nfo \\bfa-dc01\logon$\%computername%.nfo

:end

news.vbs:
  Set IECls = CreateObject("InternetExplorer.Application")
 
  With IECls
       .FullScreen = false
       .Width = 1025
       .Height = 700
       .toolbar=false
       .menubar=false
       .addressbar=false
       .statusbar=false
       .resizable=false
       .navigate("\\***-DC02\netlogon\html\***news.html")
       .visible = true
       
    End With  






0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now