#33641 - 2002-11-29 12:06 AM
Check if a share is mapped to
|
Julian
Starting to like KiXtart
Registered: 2000-04-20
Posts: 112
Loc: Newcastle, Staffs, UK
|
Hi,
I was wondering if anybody could help me. I have written a script to move the user directories from one server to another. First of all in unshares the directory then copies it to the new location and then reshares it. I was wondering if there is a way i can check if that users directory is been mapped to before i unshare it so there is no chance of data loss. here is the code below:
code:
;Start Move $UserDirList="G:\MoveDirs\Dirs.txt" Open(1,$UserDirList,2) $Dir=Readline(1) While $Dir<>"" $SourceShare=$SourceServer + $Dir ; Share on source server to be removed $DestShare=$DestServer + $Dir ; Share on destination server to be created $SourceUserDir=$SourceDir + $Dir ; Path of the user dir on source server $DestUserDir=$DestSharePath + $Dir ; Path of the user dir on destination server $RmtUserDir=$MappedDrive + $Dir ; Location on the source server of the destination path Shell "RmtShare $SourceShare /DELETE" Shell "Robocopy $SourceUserDir $RmtUserDir /E /SEC /MOVE /XF paradox.cfg /+LOG:MoveUserDir.txt" Shell "RmtShare $DestShare=$DestUserDir" Shell "NTUser -s $PDC change $Dir -home_dir $DestServer$Dir -home_dir_drive $HomeDirDrive" $Dir=Readline(1) Loop Close(1) Return
I basically like something in the code that checks if the share is in use, if it is then it skips the whole lot.
any ideas?
thanks
|
|
Top
|
|
|
|
#33644 - 2002-11-28 03:26 PM
Re: Check if a share is mapped to
|
Julian
Starting to like KiXtart
Registered: 2000-04-20
Posts: 112
Loc: Newcastle, Staffs, UK
|
Thanks for your input but I think we may be on cross purposes here. I want to be able to check whether or not somebody, the user, is mapped to the share on the server. The USE LIST command just tells which drives are mapped on the server .
The scernario goes. The script fisrt checks if any user is mapped to the share, if not its unshared, moved, then reshared. If a user is mapped to it, it is just ignored.
Sorry if I didnt explain my self to well.
Ju
|
|
Top
|
|
|
|
#33645 - 2002-11-28 03:38 PM
Re: Check if a share is mapped to
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
You want to check the server share for active connections, right?
This can be done. If I can not find a way to get this info via COM I will add the functionality to my Win32Admin.DLL.
|
|
Top
|
|
|
|
#33646 - 2002-11-28 03:39 PM
Re: Check if a share is mapped to
|
Julian
Starting to like KiXtart
Registered: 2000-04-20
Posts: 112
Loc: Newcastle, Staffs, UK
|
thats right yes. thankyou.
|
|
Top
|
|
|
|
#33647 - 2002-11-28 03:45 PM
Re: Check if a share is mapped to
|
Kdyer
KiX Supporter
   
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
What about -
IF EXIST("E:\") ..
or
IF GETFILEATTR("E:\") & 16 ..
HTH,
Kent
|
|
Top
|
|
|
|
#33648 - 2002-11-28 03:56 PM
Re: Check if a share is mapped to
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
Today is a U.S. holiday. I will not be able to get to this until after dinner. It may be easier for me to provide you an EXE that does the whole thing since I already have most of this coded in Perl for something I have already done. Would that be acceptable? [ 28. November 2002, 15:57: Message edited by: Howard Bullock ]
|
|
Top
|
|
|
|
#33649 - 2002-11-28 03:58 PM
Re: Check if a share is mapped to
|
Julian
Starting to like KiXtart
Registered: 2000-04-20
Posts: 112
Loc: Newcastle, Staffs, UK
|
That would be fantastic. Will it be fairly straigtforward to incorporate it into my script?
|
|
Top
|
|
|
|
#33650 - 2002-11-28 03:59 PM
Re: Check if a share is mapped to
|
Julian
Starting to like KiXtart
Registered: 2000-04-20
Posts: 112
Loc: Newcastle, Staffs, UK
|
kdyer - Im sorry im not quite with you on that, how would those commands help?
|
|
Top
|
|
|
|
#33652 - 2002-11-28 04:12 PM
Re: Check if a share is mapped to
|
Julian
Starting to like KiXtart
Registered: 2000-04-20
Posts: 112
Loc: Newcastle, Staffs, UK
|
Thats exactly it. Ive had a good look the the resource kits but cant seem to find a tool that would fit my needs.
|
|
Top
|
|
|
|
#33653 - 2002-11-28 04:18 PM
Re: Check if a share is mapped to
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
My two thoughts are that: 1) I would add a method to the Win32Admin.DLL that would query the sever for the number of connections or list of accounts connected to the share. Or 2) I would replace your entire script with an executable that would accept command line parms and do your task end to end.
|
|
Top
|
|
|
|
#33654 - 2002-11-28 04:21 PM
Re: Check if a share is mapped to
|
Julian
Starting to like KiXtart
Registered: 2000-04-20
Posts: 112
Loc: Newcastle, Staffs, UK
|
I think your going past the realsm of my understanding there Howard.
I havnt got a clue how to turn my entire scrip into an .exe.
maybe one day.
|
|
Top
|
|
|
|
#33655 - 2002-11-28 04:27 PM
Re: Check if a share is mapped to
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
My second option is to write what you want in Perl, compile it for you, and provide a complete solution that you could use.
|
|
Top
|
|
|
|
#33656 - 2002-11-28 04:31 PM
Re: Check if a share is mapped to
|
Julian
Starting to like KiXtart
Registered: 2000-04-20
Posts: 112
Loc: Newcastle, Staffs, UK
|
Well. Ofcourse that would be fantastic but I really would'nt want to put you out. Its quite cheeky.
How do you run a Perl script anyway? Ive heard so much about them recently but have never looked into them.
|
|
Top
|
|
|
|
#33658 - 2002-11-28 04:46 PM
Re: Check if a share is mapped to
|
Julian
Starting to like KiXtart
Registered: 2000-04-20
Posts: 112
Loc: Newcastle, Staffs, UK
|
One command I have come across is the NET SHARE 'ShareName' which displays all users currently connected to that particular share amongst other information. However I wouldnt know how to use the output in my script.
|
|
Top
|
|
|
|
#33659 - 2002-11-29 05:32 AM
Re: Check if a share is mapped to
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
Julian, you can now use Win32Admin.DLL to check the number of active connections to a remote share. You can create a share, delete a share, get/set share properties on a remote server.
You can also use the DLL to get/set user account properties such as home directory and home drive.
|
|
Top
|
|
|
|
#33660 - 2002-12-02 11:32 AM
Re: Check if a share is mapped to
|
Julian
Starting to like KiXtart
Registered: 2000-04-20
Posts: 112
Loc: Newcastle, Staffs, UK
|
Thanks very much for your help with this. I am going to give it a go tonight.
Thanks
Ju
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
1 registered
(Allen)
and 1198 anonymous users online.
|
|
|