Copy share-settings between two computers.

  • Thread starter Thread starter Martin Rådbo
  • Start date Start date
M

Martin Rådbo

Probably easy but I can't figure out how.

Two computers running Windows 2000 Server, pc1 and pc2, both domain
controllers for the same domain.
We often add a share (we share a folder) at pc1 with some permissions. I
would like a simple way of getting the same share to be added to pc2.

One way is to do it manually. Another way is to export the registry key
containing share information from pc1 and go to pc2 and import it. Both
methods needs a lot of manual work and it is easy to forget something.

One idéa is to use the regedit command in a batch file to first export from
pc1 and then import to pc2, but I do not know how to be able to run the
batch file from either computer and at the same time be able to reach the
other computers registry in the batch script.

Any other idea?

Regards
Martin Rådbo
Teknologia
 
Martin Rådbo said:
Probably easy but I can't figure out how.

Two computers running Windows 2000 Server, pc1 and pc2, both domain
controllers for the same domain.
We often add a share (we share a folder) at pc1 with some permissions. I
would like a simple way of getting the same share to be added to pc2.

One way is to do it manually. Another way is to export the registry key
containing share information from pc1 and go to pc2 and import it. Both
methods needs a lot of manual work and it is easy to forget something.

One idéa is to use the regedit command in a batch file to first export from
pc1 and then import to pc2, but I do not know how to be able to run the
batch file from either computer and at the same time be able to reach the
other computers registry in the batch script.

Any other idea?

Regards
Martin Rådbo
Teknologia

You could do it with this batch file:

Line1 @echo off
Line2 set Server1=ett
Line3 set Server2=två
Line4 if %ComputerName%==%Server1% (set Remote=Server2) else (set
Remote=Server1)
Line5
Line6 echo.
Line7 set /p Share=Please enter the name of the new share:
Line8 if "%Share%"=="" goto :eof
Line9 set /p Folder=Please enter the path and name of the folder for this
share:
Line10 if "%Folder%"=="" goto :eof
Line11
Line12 if not exist "%Folder%" md "%Folder%"
Line13 net share %Share%="%Folder%"
Line14
Line15 echo if not exist "\%Folder%" md "\%Folder%" > \\%Remote%\c$\temp.bat
Line16 echo net share %Share%="%Folder%" >> \\%Remote%\c$\temp.bat
Line17 psexec \\%Remote% c:\temp.bat

And here is how it works:
Lines 2 & 3 let you set the NetBIOS name of your two servers.
Line 4 sets the name of the "remote" server so that you can run
this batch file from either server. It is completely symmetrical.
Lines 7 and 9 prompt you to enter the name of the share and the
fully qualified name of the folder, e.g. d:\shares\new folder. Do
not enter any double quotes!
Lines 12 and 13 create the folder and the share.
Lines 15 and 16 create an auxiliary batch file on the remote server.
Line 17 starts a process on the remote server that runs the auxiliary
batch file, which will create the folder and the share.

You can get psexec.exe from www.sysinternals.com.
 
Back
Top