[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

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

Posted on 2010-04-06
20
Medium Priority
?
714 Views
Last Modified: 2012-05-09
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
0
Comment
Question by:venmarces
  • 9
  • 7
  • 3
  • +1
20 Comments
 
LVL 12

Expert Comment

by:Craig Bowman
ID: 29930841
if you wanted to call the folder "Temp"  the folder creation portion would be

MD C:\TEMP


0
 
LVL 5

Accepted Solution

by:
jkinwv09 earned 1200 total points
ID: 29931195
cd\
c:
MD Foldername
net share temp=c:\foldername
cacls foldername /g Toto:f
0
 
LVL 66

Assisted Solution

by:johnb6767
johnb6767 earned 300 total points
ID: 29934842
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
[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

 
LVL 66

Expert Comment

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

0
 
LVL 5

Assisted Solution

by:jkinwv09
jkinwv09 earned 1200 total points
ID: 29935754
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
 
LVL 5

Expert Comment

by:jkinwv09
ID: 29935820
change as you need it and save as vbs, run from a bat as cscript shortcut.vbs
0
 

Author Comment

by:venmarces
ID: 29938973
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
 

Author Comment

by:venmarces
ID: 30029157
can someone help me to fix this
0
 
LVL 66

Expert Comment

by:johnb6767
ID: 30074637
Did you try the util above for the shortcut creation?
0
 

Author Comment

by:venmarces
ID: 30112876
yes and I didn't get the expecte results
0
 
LVL 5

Expert Comment

by:jkinwv09
ID: 30129562
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
 
LVL 5

Expert Comment

by:jkinwv09
ID: 30211789
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
 

Author Comment

by:venmarces
ID: 30215739
it is a domain user
0
 
LVL 5

Expert Comment

by:jkinwv09
ID: 30217960
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
 
LVL 5

Assisted Solution

by:jkinwv09
jkinwv09 earned 1200 total points
ID: 30219039
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
 

Author Comment

by:venmarces
ID: 30409165
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
 
LVL 5

Expert Comment

by:jkinwv09
ID: 30621789
Did you plug in your domain in Domain and User in user or did you run as is?
0
 

Author Comment

by:venmarces
ID: 30623157
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
 
LVL 5

Assisted Solution

by:jkinwv09
jkinwv09 earned 1200 total points
ID: 30624018
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
 

Author Closing Comment

by:venmarces
ID: 31711464
ok
0

Featured Post

2018 Annual Membership Survey

Here at Experts Exchange, we strive to give members the best experience. Help us improve the site by taking this survey today! (Bonus: Be entered to win a great tech prize for participating!)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of the companies I’ve worked with have embraced cloud solutions due to their desire to “get out of the datacenter business.” The ability to achieve better security and availability, and the speed with which they are able to deploy, is far grea…
Files go missing when using DFS (Distributed File System) Replication and how to recover them and fix it.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Suggested Courses

608 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question