Batch file to create a folder and make a shortcut in the desktop

Hi

I want to make a batch file that will do the following :  
- Create a folder on C:\ of each workstation
- Share this folder and give full access to a specific user "Toto"
- Create a shortcut of this folder on the desktop of each workstation

How I can do that
venmarcesAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Craig BowmanIT Services ManagerCommented:
if you wanted to call the folder "Temp"  the folder creation portion would be

MD C:\TEMP


0
jkinwv09Commented:
cd\
c:
MD Foldername
net share temp=c:\foldername
cacls foldername /g Toto:f
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
johnb6767Commented:
Dont know of a way to create the shortcut via command line natively......... but this is something you can reference via a network path, or copy it locally....


SHORTCUT.exe (NT Server Resource Kit)
http://ss64.com/nt/shortcut.html

0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

johnb6767Commented:
Or create a shortcut 1 time, and copy it over via batch from a network share to %allusersprofile% or %userprofile%

0
jkinwv09Commented:
I create a desktop shortcut with a vb script
Set objShell = CreateObject("Wscript.Shell")
strDesktop = objShell.SpecialFolders("Desktop")

Set objShortcut = objShell.CreateShortcut(strDesktop & "ICON.lnk")
objShortcut.TargetPath = "C:\Foldername"
objShortcut.Arguments = ""

objShortcut.Description = "Shared"
objShortcut.WorkingDirectory = "C:\foldername"

objShortcut.Save
0
jkinwv09Commented:
change as you need it and save as vbs, run from a bat as cscript shortcut.vbs
0
venmarcesAuthor Commented:
I tried your scripts and here is what I have ....

The Folder is created and Shared but I can't give the specific user Full permissions on the folder

The shorcut is not created even with the VBScript code

Thanks
cd\
del %userprofile%\Desktop\Scan
c:
MD Scan
net share Scan=c:\Scan
cacls Scan /e /g ScanTestUser:f
cscript shortcut.vbs
Pause

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
I create a desktop shortcut with a vb script
Set objShell = CreateObject("Wscript.Shell")
strDesktop = objShell.SpecialFolders("Desktop")

Set objShortcut = objShell.CreateShortcut(strDesktop & "ICON.lnk")
objShortcut.TargetPath = "C:\Scan"
objShortcut.Arguments = ""

objShortcut.Description = "Shared"
objShortcut.WorkingDirectory = "C:\Scan"

objShortcut.Save

Open in new window

0
venmarcesAuthor Commented:
can someone help me to fix this
0
johnb6767Commented:
Did you try the util above for the shortcut creation?
0
venmarcesAuthor Commented:
yes and I didn't get the expecte results
0
jkinwv09Commented:
Set objShell = CreateObject("Wscript.Shell")
strDesktop = objShell.SpecialFolders("Desktop")
 
Set objShortcut = objShell.CreateShortcut(strDesktop & "\Scan.lnk")
objShortcut.TargetPath = "C:\Scan"
objShortcut.Arguments = "" 
 
objShortcut.Description = "Shared"
objShortcut.WorkingDirectory = "C:\Scan"
 
objShortcut.Save

Try that instead
0
jkinwv09Commented:
About the user permissions is this a local user or a network user, I need to understand your network better.  Does this account exist locally, is it a peer to peer, or a domain?
0
venmarcesAuthor Commented:
it is a domain user
0
jkinwv09Commented:
You have to include the domain name in the argument for the user
cd\
del %userprofile%\Desktop\Scan
c:
MD Scan
net share Scan=c:\Scan
cacls Scan /e /g DOMAIN\ScanTestUser:f
cscript shortcut.vbs
Pause
0
jkinwv09Commented:
cd\
del c:\Scan
c:
MD Scan
net share Share=c:\Scan /grant:Domain\User,FULL
cacls Scan /e /g Domain\user:f
cscript shortcut.vbs
Pause
 
and use this like this
0
venmarcesAuthor Commented:
I got this error when I executed : cacls Scan /e /g Domain\user:f

"No Mapping between account names and security id's were done"
0
jkinwv09Commented:
Did you plug in your domain in Domain and User in user or did you run as is?
0
venmarcesAuthor Commented:
yes and now it is working well .....
But How I can add a new permission security on my share and give it full control

I tried this : net share Scan=c:\Scan /grant:scanricoh,full

But it seems there is an error .... don't know the option : grant:scanricoh,full
 
0
jkinwv09Commented:
It may work out easier for you to set the folders shared permissions to everyone full, and then set the domain\user permissions for the user on the folder. NTFS permissions will supercede Share permissions every time. otherwise you may want to look at something like this as a solution http://setacl.sourceforge.net/index.html for the permissions part.
0
venmarcesAuthor Commented:
ok
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
File Sharing Software

From novice to tech pro — start learning today.