Solved

Samba batch.bat script

Posted on 2004-09-16
8
613 Views
Last Modified: 2012-05-05
Hello exerts ,

I need to know if it is possible to write batch.bat script for my win 98clients which will recognize who is going to log in and then run the appropriate command? Something like this:

if user foo then

net use commands

elseif user bar then

net use commands

else

net use commands

end if

but I do not know how to pass variable with user name to this script
-----
or
------
how to setup smb.conf to run foo.bat batch file when foo user login and if bar user login run bar.bat file and if some others clients login run batch.bat file .

Thanks

Luxana

0
Comment
Question by:Luxana
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 5

Expert Comment

by:paranoidcookie
ID: 12082324
You can use command switches I think its %u for username

so

net use h: \\server\%u

Set up a share called netlogon then use a dos editior (it must add the carrage return line feed symbols al la windows, you can use the linux tool "todos" on the file if you cant use a dos editor.) to create the batch file then save it in netlogon.
There is then an option in smb.conf logon script = yourfile.bat

Hope that helps
0
 
LVL 10

Author Comment

by:Luxana
ID: 12083240
I'm now able to map my clients home drivers with:

NET USE P: /HOME /YES

smb.conf :
logon home = \\lindsor\%u
[homes]
read only = no
browseable = no
writable = yes
valid users = %S
read only = no
create mode = 0600
directory mode = 0700

The point is that I need for user foo when he login to win98 map his home directory and also some other samba shares. But when user bar will logon it will map just his home directory.

this setting in smb.conf accept file batch.bat and %U.bat is ignored
logon script = %U.bat
logon script = batch.bat

this setting in smb.conf accept file %U.bat and batch.bat is ignored
logon script = batch.bat
logon script = %U.bat

thanks
0
 
LVL 6

Expert Comment

by:knollbert
ID: 12085079
Only one log on script is allowed, to my knowlege, so the last one is used

Modify the foo.bat (%U.bat) startup script to do run the net use command in windows

Make the batch file in windows, as suggested by the samba team
0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
LVL 5

Expert Comment

by:paranoidcookie
ID: 12085165
If you use %u.bat as the files name samba will look for a logon script with the users name in it create a batch file called logon.bat with the contents

net use h:\ \\server\drive\%u
net use z:\ \\server\share

This should be executed for each user that logs on
0
 
LVL 10

Author Comment

by:Luxana
ID: 12099746
if i understand clearly

net use h:\ \\server\drive\%u   -> this will run user home directory
net use z:\ \\server\share  -> this will run some other share

and also it means that I need to create batch file for all users each ?

0
 
LVL 1

Expert Comment

by:ozcokedrinker
ID: 12110715
how about :

if %u = foo then
net use commands
elseif %u = bar then
net use commands
else
net use commands

0
 
LVL 1

Accepted Solution

by:
ozcokedrinker earned 500 total points
ID: 12110807
Or you could use groups, with a batch file for each group of users.

you could use the following in you smb.conf:

login script = %G.bat

where %G is the group name.
0
 
LVL 10

Author Comment

by:Luxana
ID: 12158090
ozcokedrinker,

thanks for your alternative advise :) it was the best idea I think. What I did was that I created script to help me change my users primary group and then just put  login script = %G.bat to smb.conf and created two batch.bat files with different map commands.

Lubos
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Over the last ten+ years I have seen Linux configuration tools come and go. In the early days there was the tried-and-true, all-powerful linuxconf that many thought would remain the one and only Linux configuration tool until the end of times. Well,…
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question