Creating a script to share folders, having format issues.
Below works from CMD, but not the spaces:
mkdir "C:\Program Files (x86)\Blank"
net share "Blank=c:\Program Files (x86)\Blank" /GRANT:everyone,full
not working:
net share "Blank blank blank blank"=C:\"Program Files
(x86)\Blank blank blank blank" /grant:everyone,full
How do I format this in a script to get the brackets and spaces in CMD?
'CMD is run as administrator.
'Then the script is run from CMD, by typing the name/location of the script.
'The sendkeys function is typing into CMD.
'Below is the .vbs
dim filesys
set f=CreateObject("Scripting.FileSystemObject")
Set ws = Wscript.CreateObject("Wscript.Shell")
ws.sendkeys "mkdir ""C:\Program Files {(}x86{)}\Blank blank blan blank"""
ws.sendkeys "{enter}"
wscript.sleep 1000
ws.sendkeys "net share ""Blank blank blank blank""=C:\""Program Files
{(}x86{)}\Blank blank blank blank"" /grant:everyone,full"
ws.sendkeys "{enter}"
This adds the (), but I get a syntax error (below). Below is the CMD output with error.
C:\Scripts>net share "Blank blank blank blank"=C:\"Program Files
(x86)\Blank blank blank blank" /grant:everyone,full
The syntax of this command is:
NET SHARE
sharename
sharename=drive:path [/GRANT:user,[READ | CHANGE | FULL]]
[/USERS:number | /UNLIMITED]
[/REMARK:"text"]
[/CACHE:Manual | Documents| Programs |
BranchCache | None]
sharename [/USERS:number | /UNLIMITED]
[/REMARK:"text"]
[/CACHE:Manual | Documents | Programs | BranchCache |
None]
{sharename | devicename | drive:path} /DELETE
sharename \\computername /DELETE