creating a batch file to map a users home drive on the network.

hi,
I want to create a file that can be sent out to all users in the company, that once they click on it will map a drive to their home folder on the network and also place a shortcut on the desktop, anyone know if this can be done and how to.
Thanks
Techno-Man-ukAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
sirbountyConnect With a Mentor Commented:
Are you in a domain?  You can use a logon script for this
net use h: \\servername\%username%
0
 
Techno-Man-ukAuthor Commented:
yes in a domain, I have used the above in Active Directory, but before I joined the company this wasn't enforced so I don't want to have to go through all the accounts looking at who has and hasn't got their drive mapped.
I just want a simple file they can click and it does all the work
0
 
qqtpieCommented:
Would all of the users be mapping to the same file name? Example: \anyserver\myfolder , or do they each have a specific folder name \anyserver\johnsmith?
Do they need to log in to the server?
0
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
Techno-Man-ukAuthor Commented:
all users folders are kept in a central location on 1 server under a shared folder called users
eg
\\myserver\users\username

0
 
qqtpieCommented:
so would you want them to enter specific data from command prompt?

SET /P variable=[promptString]

set /p user=Please enter your user name:
echo Hello, %NAME%
0
 
Techno-Man-ukAuthor Commented:
Well no I want something like a batch file that they can click and it will run some script to map their home drive and make a desktop shortcut.
0
 
qqtpieCommented:
Do the users log in to the shared drive on the server? If they log in, could you have the files stored on the server itself and the batch file could run then? net use k: \\myserver\users\username /yes
0
 
qqtpieCommented:
Could it be a batch file to add a shortcut that is pre-configured with the target and start-in values?
0
 
qqtpieCommented:
name it shortcut.bat

@echo off

copy k:\shortcut.lnk %username%\Desktop

add to script:

call shortcut.bat
0
 
Techno-Man-ukAuthor Commented:
that doesn't seem to work
0
 
sirbountyConnect With a Mentor Commented:
Adapted from http://www.computerperformance.co.uk/ezine/ezine119.htm & http://www.computerperformance.co.uk/ezine/ezine30.htm
' CreateShortCut.vbs - Create a Desktop Shortcut.
' VBScript to create .lnk file
' Author Guy Thomas http://computerperformance.co.uk
' Version 2.4 - July 2006
' ----------------------------------------------------------' 
Option Explicit
Dim objShell, objDesktop, objLink
Dim strAppPath, strWorkDir, strIconPath
Set objShell = CreateObject("WScript.Shell")
 
' --------------------------------------------------
' Here are the variables that to change if you are making a 'real' script
 
'strWorkDir ="C:\windows"
strServer = "\\YourServer\"
strAppPath = strServer & objShell.ExpandEnvironmentStrings("%username%") '"%SystemRoot%\notepad.exe"
'strIconPath = "%SystemRoot%\system32\SHELL32.dll,5"
strDrive = "H:"
 
Set objNetwork = CreateObject("WScript.Network") 
objNetwork.MapNetworkDrive strDrive, strAppPath
 
objDesktop = objShell.SpecialFolders("Desktop")
Set objLink = objShell.CreateShortcut(objDesktop & "\HomeShare.lnk")
 
' ---------------------------------------------------
' Section which adds the shortcut's key properties
 
objLink.Description = "HomeShare"
'objLink.HotKey = "CTRL+SHIFT+X"
'objLink.IconLocation = strIconPath 
objLink.TargetPath = strAppPath
objLink.WindowStyle = 3
'objLink.WorkingDirectory = strWorkDir
objLink.Save
 
WScript.Quit
 
' End of creating a desktop shortcut

Open in new window

0
 
sirbountyCommented:
Glad I could help - thanx for the grade! :^)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.