Sharing a folder through CMD script:
This might possibly be a need while automating a share on a specific condition.
Here in, our requirement was to start a share of the folder for multiple users based on SQL Agent Start. This can be done by the following steps.
The approach is to have a .bat file with the command that shares the folder. Later, the bat file can be called from SQL Agent Job Step.
The command is:
NET SHARE XXX$=E:\MyFolder /GRANT:SQLServer2005SQLAgentUser,FULL /GRANT:SQLServerSQLUser,FULL /GRANT:"Database Administrators",FULL /GRANT:EVERYONE,READ
For Help in Command Prompt: NET SHARE /help
Note: Share resource names that end in a $ character do not appear when you browse the local computer from a remote computer.
The .bat file can be created by pasting the command above in any text editor and the file can be saved by the extension .bat.
The .bat file can be called from the agent job step as
Choose the Job Step Type as OperatingSystem (CmdExe)
In the command window:
cmd.exe /c "E:\ShareFolder.bat"
that calls the .bat file.
The job can be scheduled to start on SQL Agent Start in the schedule section of the job.
Ref:
http://technet.microsoft.com/en-us/library/hh750728(v=ws.10).aspx
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/cmd.mspx?mfr=true
http://www.techotopia.com/index.php/Using_NET_SHARE_to_Configure_Windows_Server_2008_File_Sharing
This might possibly be a need while automating a share on a specific condition.
Here in, our requirement was to start a share of the folder for multiple users based on SQL Agent Start. This can be done by the following steps.
The approach is to have a .bat file with the command that shares the folder. Later, the bat file can be called from SQL Agent Job Step.
The command is:
NET SHARE XXX$=E:\MyFolder /GRANT:SQLServer2005SQLAgentUser,FULL /GRANT:SQLServerSQLUser,FULL /GRANT:"Database Administrators",FULL /GRANT:EVERYONE,READ
For Help in Command Prompt: NET SHARE /help
Note: Share resource names that end in a $ character do not appear when you browse the local computer from a remote computer.
The .bat file can be created by pasting the command above in any text editor and the file can be saved by the extension .bat.
The .bat file can be called from the agent job step as
Choose the Job Step Type as OperatingSystem (CmdExe)
In the command window:
cmd.exe /c "E:\ShareFolder.bat"
that calls the .bat file.
The job can be scheduled to start on SQL Agent Start in the schedule section of the job.
Ref:
http://technet.microsoft.com/en-us/library/hh750728(v=ws.10).aspx
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/cmd.mspx?mfr=true
http://www.techotopia.com/index.php/Using_NET_SHARE_to_Configure_Windows_Server_2008_File_Sharing
Comments
Post a Comment