Jump to content

Welcome to MSFN Forum
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account


Photo

How to automate setting advanced sharing


  • Please log in to reply
7 replies to this topic

#1
alanfox

alanfox
  • Member
  • 5 posts
  • OS:Windows 7 x64
  • Country: Country Flag
I want to be able to automate setting advanced sharing, public folder sharing and password protected sharing. I want to be able to do this via command line, vbscript, reg hack, ... However I can. I've googled and binged for days. Tried using regshot to look at before/after registry settings when I manually changed them. Nothing. Any help would be great. Or even if I can find where the settings are stored would be helpful. I can set network discovery and file and printer sharing with "netsh advfirewall firewall set rule group=" but there are no groups/rules for public folder sharing and password proteced sharing. Thank you.


How to remove advertisement from MSFN

#2
harshadhparulekar

harshadhparulekar

    Newbie

  • Member
  • 14 posts
  • OS:Windows 7 x64
  • Country: Country Flag
Try using AutoIT v3

Use its Au3Record.exe to record all your key strokes and mouse clicks to setup your "advanced sharing". Also use it to de-setup/remove the "advanced sharing". Then use Aut2Exe.exe which comes with the AutoIT setup to generate an executable file from the recorded ".au3" file. Use the generated exe files as you want. The task will be automated, you just have to run the exe file. Most AutoIT users record only keystrokes and not mouse clicks to perform their automated tasks. This is because if the screen resolution is different than the one on which the script was recorded then the mouse clicks will not work as the x & y co-ordinates will change and the click will happen somewhere else than the intended position. Another recommendation is to stop using the keyboard and mouse when the Automated task is happening through the generated file.
Modding Windows...

#3
CoffeeFiend

CoffeeFiend

    Coffee Aficionado

  • Super Moderator
  • 5,399 posts
  • OS:Windows 7 x64
  • Country: Country Flag
The standard way to manipulate network shares is using WMI, either via vbscript or powershell (both of which are built into Windows)

Here's a quick example on technet's scripting guys that shows (and explains) how it works using powershell and here's the MSDN documentation for the Win32_Share class which you need to use.

TL;DR: it's a 2 liner in powershell:
$somevarname=[WMICLASS]"Win32_Share"
$somevarname.Create("c:\somepath","SomeShareName",0)
...unless you don't plan on doing anything else with shares, then you can even make it a one liner:
[WMICLASS]"Win32_Share"|%{$_.Create("c:\somepath","SomeShareName",0)}
It needs to be run elevated of course. You may want to change the share or NTFS permissions too.
Coffee: \ˈkȯ-fē, ˈkä-\. noun. Heaven in a cup. Life's only treasure. The meaning of life. Kaffee ist wunderbar. C8H10N4O2 FTW.

#4
alanfox

alanfox
  • Member
  • 5 posts
  • OS:Windows 7 x64
  • Country: Country Flag
Thanks to everyone. I do not need a simple file share, I need to set advanced sharing options. I beleive that Au3Record may do what I want and I will try it. Thank you.

#5
CoffeeFiend

CoffeeFiend

    Coffee Aficionado

  • Super Moderator
  • 5,399 posts
  • OS:Windows 7 x64
  • Country: Country Flag

I do not need a simple file share, I need to set advanced sharing options.

Like I said, this creates a standard network share (not some sort of simplified share). If you want to set advanced options like permissions then you have to to it after (it's not magic). WMI is the standard, built-in way that MS gives admins to administer network shares (and lots of other things).
Coffee: \ˈkȯ-fē, ˈkä-\. noun. Heaven in a cup. Life's only treasure. The meaning of life. Kaffee ist wunderbar. C8H10N4O2 FTW.

#6
alanfox

alanfox
  • Member
  • 5 posts
  • OS:Windows 7 x64
  • Country: Country Flag
This is what I need to automate:

From Network and Sharing Center, select Advanced Sharing Options and on that windows set Public Folder Sharing and Password Protected Sharing toggles.

If I can do that from WMI I would be VERY happy. But I am unable to find WMI classes that affect these two settings.

#7
CoffeeFiend

CoffeeFiend

    Coffee Aficionado

  • Super Moderator
  • 5,399 posts
  • OS:Windows 7 x64
  • Country: Country Flag
If you look around, you'll even find pre-made scripts to do just this. That should serve as a good starting point.
Coffee: \ˈkȯ-fē, ˈkä-\. noun. Heaven in a cup. Life's only treasure. The meaning of life. Kaffee ist wunderbar. C8H10N4O2 FTW.

#8
alanfox

alanfox
  • Member
  • 5 posts
  • OS:Windows 7 x64
  • Country: Country Flag
I'm sorry, I am either very thick, or I'm not properly explaining what I want to do.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users



How to remove advertisement from MSFN