Author Topic: A simple logon script for Windows clients logging into an eBox PDC  (Read 24355 times)

scottgutman

  • Zen Apprentice
  • *
  • Posts: 30
  • Karma: +0/-0
    • View Profile
Re: A simple logon script for Windows clients logging into an eBox PDC
« Reply #15 on: December 15, 2009, 04:33:39 pm »
If you want to change the way drives are named in my computer, you can incorporate this script  into your logon script to give the drives friendly names

ie
Company(\\192.168.1.1\share\all)(q:)
becomes
Company(q:)

'==========================================================================
On Error Resume Next
Dim fso, ws, wn, wd, wsEnv, oApar, oW2M, strDriveLetter, sUNC, strNewNam
Set wn = CreateObject("WScript.Network")
Set fso = CreateObject("Scripting.FileSystemObject")
Set ws = CreateObject("Wscript.Shell")
Set oShellApp = CreateObject("Shell.Application")

'Connect drive
MapTheDrive ("i:", "\\192.168.1.1\share\all\company","Company")

'==========================================================================
CleanUp

Sub CleanUp
   Set wn = Nothing
   Set fso = Nothing
   Set ws = Nothing
   Set oShellApp = Nothing
End Sub


Sub   FolderNameChange (strDriveLetter, strNewName)
   oShellApp.NameSpace(strDriveLetter).Self.Name = strNewName
End Sub

Sub MapTheDrive (strDriveLetter, sUNC, strNewName)
   If Not fso.DriveExists (strDriveLetter) Then
      wn.MapNetworkDrive strDriveLetter, sUNC
   End If
   FolderNameChange strDriveLetter, strNewName
   If Not fso.DriveExists (strDriveLetter) Then
      msgbox "Unable to connect to " & strDriveLetter & " Drive"
   End If
End Sub

philmills

  • Zen Warrior
  • ***
  • Posts: 161
  • Karma: +8/-0
    • View Profile
Re: A simple logon script for Windows clients logging into an eBox PDC
« Reply #16 on: December 23, 2009, 03:17:07 pm »
great script!
tried to get this working in 1.3.6, but it failed to map the group shares.
working fine in 0.2 though, so i guess I'll stick with that for now.

philmills

  • Zen Warrior
  • ***
  • Posts: 161
  • Karma: +8/-0
    • View Profile
Re: A simple logon script for Windows clients logging into an eBox PDC
« Reply #17 on: January 12, 2010, 05:03:33 pm »
scrub that - all working like a dream in 1.3.6 too now ;)

vovelee

  • Zen Apprentice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: A simple logon script for Windows clients logging into an eBox PDC
« Reply #18 on: January 26, 2010, 01:06:41 pm »
Everything works fine on Ebox 1.3.14!!! Tested on WindowsXP, WindowsVista Ultimate, Windows7 Enterprise 32&64 bit.


I have a question. Is there a way I can find out what type of Windows the user is using at the moment of logiing in?

For example:

If it's XP - nothing to do.
If it's Vista - put something like this
Quote
" ; Turn off New Program Highlighting
        $ = WriteValue("Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "Start_NotifyNewApps", "0", "REG_SZ")

       ; Turn off Balloon Notifications
        $ = WriteValue("Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "EnableBalloonTips", "0", "REG_DWORD")"


because poledit doesn't work on Vista & 7.
« Last Edit: January 26, 2010, 01:08:54 pm by vovelee »
Ebox Server 1.3.15

philmills

  • Zen Warrior
  • ***
  • Posts: 161
  • Karma: +8/-0
    • View Profile
Re: A simple logon script for Windows clients logging into an eBox PDC
« Reply #19 on: March 18, 2010, 12:10:06 pm »
TIP:

If you would rather allow this script to map the users home folder (this script maps it with the users name, which i think is better), and stop samba from mapping the Home folder to H: (default)  do the following:

edit this file:
Code: [Select]
/usr/share/ebox/stubs/samba/smb.conf.masfind this:
Code: [Select]
logon drive = <% $drive %>comment it out like this:
Code: [Select]
# logon drive = <% $drive %>restart samba

The logon.vbs may fail to map all drives if you already have existing drives mapped to any of the letters used in your logon.vbs
In this case you should cleanup existing drives first in logon.bat

My new logon.bat looks like this:
Code: [Select]
@echo off
@if exist o: net use o: /delete /yes
@if exist p: net use p: /delete /yes
@if exist q: net use q: /delete /yes
@if exist z: net use z: /delete /yes
cscript \\myserver\netlogon\logon.vbs
obviously change the drive letters to match those on your system
« Last Edit: March 18, 2010, 12:12:24 pm by philmills »

philmills

  • Zen Warrior
  • ***
  • Posts: 161
  • Karma: +8/-0
    • View Profile
drive mapping problems
« Reply #20 on: May 20, 2010, 08:51:38 am »
If user already has any manually mapped drives it causes the script to abort even if the batch file contains commands to delete the existing mappings first.

If the script contains mappings for groups which have not yet been created (i.e you put them in the script with the intention of adding the groups later) the script will abort without mapping some, if not all drives.

Problems seem to be more common with Vista than XP...  no surprises there I guess

Does anyone have any script modifications to fix either of these problems?


« Last Edit: May 20, 2010, 09:33:03 am by philmills »

philmills

  • Zen Warrior
  • ***
  • Posts: 161
  • Karma: +8/-0
    • View Profile
Re: A simple logon script for Windows clients logging into an eBox PDC
« Reply #21 on: June 07, 2010, 05:22:06 pm »
A little update
I can cope with the drive mappings failing if users manually map drives. It seems to only occur if the existing mapping is within the range used in the script.

A more major problem is that for some reason on Vista the user's home folder does not always get mapped. Sometimes asking the user to login again fixes this, other times the user must manually run the login bat file again.

Does anyone know what might cause this?

philmills

  • Zen Warrior
  • ***
  • Posts: 161
  • Karma: +8/-0
    • View Profile
Re: A simple logon script for Windows clients logging into an eBox PDC
« Reply #22 on: December 03, 2010, 12:07:11 pm »
I have been using this script without any problems now for 7 months in a domain with 60+ users

Suddenly yesterday the group mappings stopped working, and I'm trying to fix it.
The user's home drive and public drive map perfectly, but none of the group mappings work.
Nothing has changed on the server, and all the share permissions are still correct in that the user can access the shares from \\server\sharename

Does anyone have any ideas ?

jsalamero

  • Zentyal Staff
  • Zen Hero
  • *****
  • Posts: 1419
  • Karma: +45/-1
    • View Profile
Re: A simple logon script for Windows clients logging into an eBox PDC
« Reply #23 on: December 03, 2010, 03:54:35 pm »
Did you upgrade any package on your system ? File system or database corruption ?

philmills

  • Zen Warrior
  • ***
  • Posts: 161
  • Karma: +8/-0
    • View Profile
Re: A simple logon script for Windows clients logging into an eBox PDC
« Reply #24 on: December 29, 2010, 12:17:58 am »
didn't do anything
a restart of samba seems to have fixed it though.

Barrydocks

  • Zen Warrior
  • ***
  • Posts: 145
  • Karma: +4/-0
    • View Profile
Re: A simple logon script for Windows clients logging into an eBox PDC
« Reply #25 on: February 04, 2011, 03:39:40 pm »
This is an excellent script and works perfectly (apart from mapping the users home but I think the tip posted above may fix that).

Anyway,  I would like to redirect the XP "My Documents" folder to the users /home that has been mounted as H:  How do I modify the script to allow this?

Thanks

kerridge0

  • Zen Monk
  • **
  • Posts: 57
  • Karma: +1/-0
    • View Profile
Re: A simple logon script for Windows clients logging into an eBox PDC
« Reply #26 on: March 13, 2011, 06:07:38 pm »
This seems to not be working with latest zentyal, due to the addition of zentyal-logon.bat in the netlogon share, something for Windows 7. It's automatically overwritten whenever changes are saved in the web interface.

I have added a line to:

/usr/share/ebox/stubs/samba/logon.bat.mas

underneath echo off  (so it is the 5th line):

wscript %0\..\login.vbs

this means even when changes are saved in the interface, I won't lose the automatic running of login.vbs script saved in the /home/samba/netlogon directory.

philmills

  • Zen Warrior
  • ***
  • Posts: 161
  • Karma: +8/-0
    • View Profile
Re: A simple logon script for Windows clients logging into an eBox PDC
« Reply #27 on: March 14, 2011, 08:51:55 am »
I got around the vbscript problem another way.

I have to begin by explaining that since upgrade to latest version of Zentyal, the vbscript group based drive mappings just didn't work. it maps drives ok which are "all users" drives, and it maps the users home drive, but I couldn't get it to map group drives. To date I have no solution other than to map the drives old school in the logon.bat file using "net use".

This leads me to the other workaround. I edited /usr/share/ebox/stubs/samba/smb.conf.mas, changing the logon script value:
$logon_script => 'logon.bat'  
Where logon.bat is the name of my file, not zentyal's.
This leaves me free to keep all my other crazy logon script stuff intact, as I'm using also WPKG to install and upgrade software at logon, and a whole bunch of other stuff.

Luke

  • Zen Monk
  • **
  • Posts: 77
  • Karma: +3/-0
    • View Profile
Re: A simple logon script for Windows clients logging into an eBox PDC
« Reply #28 on: March 22, 2011, 10:45:02 am »
Hi philmills!

Any news about the group mapping ? is it possible to check the ldap server for group?


philmills

  • Zen Warrior
  • ***
  • Posts: 161
  • Karma: +8/-0
    • View Profile
Re: A simple logon script for Windows clients logging into an eBox PDC
« Reply #29 on: March 22, 2011, 03:19:47 pm »
Sorry, got your email, but just crazy busy at the moment.
If I give you the script as it is, then you'll probably have a lot of trouble trying to understand it, but if you don't mind that I can send it. There are some annotations in there.
I used WPKG Express to do the WPKG stuff, as it makes centralised management of the PCs on the network a breeze. I reccommend installing it on a seperate server (can be virtualbox) though, as it might mess with Zentyal's config. The script then tells WPKG to connect to the server for the install instructions.
You'll also hit problems trying to do installs on a samba domain as standard users don't have admin rights. I worked around this by using CPAU, which effectively allows you to do "run as".

My login script does the following:
1. check if CPAU exists on the local PC, if not copy it to C:\Installs
2. check if WKPG is installed, if not install it (using CPAU)
3. detect OS - if OS is Vista or later, most of the WPKG installs just don't work due to UAC. XP is best.
4. run wpkg
5. do drive mappings


I'll take a look when I get the chance.