script to set folder shares

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
calude
Posts: 355
Joined: 13 Aug 2008 10:16
Location: Switzerland
Contact:

script to set folder shares

Post by calude »

Hi
a script that would be very useful for me

the script would set a fixed group of folders to "Share with Homegroup read and write"

Have a nice day

calude

binocular222
Posts: 1424
Joined: 04 Nov 2008 05:35
Location: Win11, Win10, 100% Scaling

Re: script to set folder shares

Post by binocular222 »

I'm a casual coder using AHK language. All of my xys scripts:
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488

calude
Posts: 355
Joined: 13 Aug 2008 10:16
Location: Switzerland
Contact:

Re: script to set folder shares

Post by calude »

thanks binocular222
I tried to understand the use of your script. seems too complicated for my simple needs

on my office PC I have a crypted partition that I first have to mount before I can do something with it.
the problem is this partition doesnt remember its shared folders.
hence the script to set the share on a max of 10, always the same folders.

anyone ?

Calude

calude
Posts: 355
Joined: 13 Aug 2008 10:16
Location: Switzerland
Contact:

Re: script to set folder shares

Post by calude »

nobody has a clue to help me ?
come on
;=)

Calude

binocular222
Posts: 1424
Joined: 04 Nov 2008 05:35
Location: Win11, Win10, 100% Scaling

Re: script to set folder shares

Post by binocular222 »

Your system is too unique.
Mount an encrypted drive at start-up then share a secific folder on it? Uhm, I have no such system to test on
I'm a casual coder using AHK language. All of my xys scripts:
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488

calude
Posts: 355
Joined: 13 Aug 2008 10:16
Location: Switzerland
Contact:

Re: script to set folder shares

Post by calude »

hi binocular222
the only part I need is set some folders to share with homegroup with a script

Calude

serendipity
Posts: 3360
Joined: 07 May 2007 18:14
Location: NJ/NY

Re: script to set folder shares

Post by serendipity »

If you are OK doing that with command line, using net share command like this for eg.:

Code: Select all

NET SHARE MyVids="D:\Videos" /GRANT:Everyone,FULL
This will share a particular folder with everyone and grant them full access.

If something like this works for you, then you can call that command line from within the XY script.

More info in NET SHARE:
http://ss64.com/nt/net_share.html

binocular222
Posts: 1424
Joined: 04 Nov 2008 05:35
Location: Win11, Win10, 100% Scaling

Re: script to set folder shares

Post by binocular222 »

My script use exactly this Net Share, but as calude described, when the encrypted drive is mounted on computer start-up, all shared information is lost, he has to share them again.
Maybe callude should add /script= to run the script at every Xyplorer start-up?
I'm a casual coder using AHK language. All of my xys scripts:
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488

serendipity
Posts: 3360
Joined: 07 May 2007 18:14
Location: NJ/NY

Re: script to set folder shares

Post by serendipity »

binocular222 wrote:My script use exactly this Net Share, but as calude described, when the encrypted drive is mounted on computer start-up, all shared information is lost, he has to share them again.
Maybe callude should add /script= to run the script at every Xyplorer start-up?
Oh sorry, did not see your script. Yes, running script at start would be the way to do it then.

calude
Posts: 355
Joined: 13 Aug 2008 10:16
Location: Switzerland
Contact:

Re: script to set folder shares

Post by calude »

I'm sorry, I'm really not computer literate "enough" :om: !!
to write this myself with the fine xy manual
tried to send some "NET SHARE sharename" with xy "run " didnt get a window back

will kindly ask for some more "code" help, and of course, running script at start could be an option, when the global script does it magic!

binocular and serendipity thanks

Calude

binocular222
Posts: 1424
Joined: 04 Nov 2008 05:35
Location: Win11, Win10, 100% Scaling

Re: script to set folder shares

Post by binocular222 »

The command-line is basically:
Net share "Name-to-Display"="Folder Path" /Grant:Everyone,Full
Here is the simple script:

Code: Select all

 run "cmd /c Net share ""Test 1""=""C:\Test 1"" /Grant:Everyone,Full";
 run "cmd /c Net share ""Test 2""=""C:\Test 2"" /Grant:Everyone,Full";
 run "cmd /c Net share ""Test 3""=""C:\Test 3"" /Grant:Everyone,Full";
 wait 500;
 #482;
 #486;
Step 1: You may need to increase/decrease wait depend on how much time your computer need to run all your Net share command (in my code, after completion of all 3 Net share, XYplorer will wait 500mili second and refresh)
Step 2: You save the code in \XYplorer\Data\Scripts\ with Sharingscript.xys
Step 3: You create a shortcut to XYplorer.exe, right click the newly created shortcut → properties → paste argument in Target field such as this:
E:\7Utilities\XYplorer\XYplorer.exe /script="Sharingscript.xys"

Now, everytime you double click the shortcut, the script will be executed, which shares all these folders.
I don't know if share those folders multiples times without unshare them will create any trouble. You may go to %net% to check for any weird things after several times running this script
Note: If this works, and you don't want black screen flashing, then you may use Nircmd such as:
run """E:\7Utilities\XYplorer\Data\Scripts\nircmd\nircmd.exe"" execmd Net share ""Test 3""=""C:\Test 3"" /Grant:Everyone,Full";

P.S: This script allow other computers to see and access folders on your computer but what's Home Group? I don't have one, so cannot say if it works.
I'm a casual coder using AHK language. All of my xys scripts:
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488

calude
Posts: 355
Joined: 13 Aug 2008 10:16
Location: Switzerland
Contact:

Re: script to set folder shares

Post by calude »

Hi
I tried the script but nothing happens on the test folders

I maybe must add that I'm running Win 7 32 and homeGroup i this:
http://windows.microsoft.com/en-us/wind ... /homegroup

Calude

binocular222
Posts: 1424
Joined: 04 Nov 2008 05:35
Location: Win11, Win10, 100% Scaling

Re: script to set folder shares

Post by binocular222 »

Try Start → Run → cmd
and type in this command:
cmd Net share "Test 3"="C:\Test 3" /Grant:Everyone,Full
Will this change the sharing status of Test 3 folder? (right click → share with → advanced sharing)
My scipt does exactly this.
P.S I'm running win 7 x32 too
I'm a casual coder using AHK language. All of my xys scripts:
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488

calude
Posts: 355
Joined: 13 Aug 2008 10:16
Location: Switzerland
Contact:

Re: script to set folder shares

Post by calude »

binocular222 wrote:Try Start → Run → cmd
and type in this command:
cmd Net share "Test 3"="C:\Test 3" /Grant:Everyone,Full
Will this change the sharing status of Test 3 folder? (right click → share with → advanced sharing)
My scipt does exactly this.
P.S I'm running win 7 x32 too
My test folder is test3 on D: so I changed the command to

cmd Net share "test3"="D:\test3" /Grant:Everyone,Full

nothing happens
the swiss french locale should'nt be different ??

Calude

binocular222
Posts: 1424
Joined: 04 Nov 2008 05:35
Location: Win11, Win10, 100% Scaling

Re: script to set folder shares

Post by binocular222 »

oh sorry, it should be
Net share "test3"="D:\test3" /Grant:Everyone,Full
the "cmd" in the beginning is redundant.
I'm a casual coder using AHK language. All of my xys scripts:
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488

Post Reply