Share/UnShare files with script?


Recommended Posts

I need to be able to unshare a directory on a server at a specific time and then reshared after a period of time.

Some of my software at work can only auto update a program if people aren't in it. People leave work and don't close the program so it won't auto update at night because of that. I have 6 remote places that use this program so it's not like I can just make sure people aren't in the program. :p

How can I do this?

Link to comment
https://www.neowin.net/forum/topic/56157-shareunshare-files-with-script/
Share on other sites

I haven't really looked into this, but my theory is:

if there is a command line "share" command, then I can schedule a *.bat file to unshare the folder between 2am to 4am and then reshare it after that using another *.bat file scheduled.

I'm going to research that and see if I can do it that way.

I believe the closest thing to a SHARE command is net share.

You could use net share sharename to start sharing and net share sharename /delete to stop the share. I'm not sure if this will do exactly what you're looking for, but it's worth a shot.

More on net share:

start > run > cmd /k net share /?

Then, the share could be scheduled with the AT command. Be sure to test it out first, because AT can be a little tricky.

More on at:

start > run > cmd /k at /?

I figured it out.

I wrote 2 batch files

sharech.bat

------------------

@echo off

net share ChromeData=G:\ChromeData

usharech.bat

------------------

@echo off

net share ChromeData /delete

I then scheduled a job to run one script at a certian time and then run the other 2 hours later.

Thanks for the feed back and help anyways. :) Neowin is always there for us computer nerds. :p

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.