Solved

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

Posted on 2009-05-14
12
1,053 Views
Last Modified: 2012-05-07
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
0
Comment
Question by:Techno-Man-uk
  • 5
  • 4
  • 3
12 Comments
 
LVL 67

Accepted Solution

by:
sirbounty earned 500 total points
Comment Utility
Are you in a domain?  You can use a logon script for this
net use h: \\servername\%username%
0
 

Author Comment

by:Techno-Man-uk
Comment Utility
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
 

Expert Comment

by:qqtpie
Comment Utility
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
 

Author Comment

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

0
 

Expert Comment

by:qqtpie
Comment Utility
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
 

Author Comment

by:Techno-Man-uk
Comment Utility
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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

Expert Comment

by:qqtpie
Comment Utility
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
 

Expert Comment

by:qqtpie
Comment Utility
Could it be a batch file to add a shortcut that is pre-configured with the target and start-in values?
0
 

Expert Comment

by:qqtpie
Comment Utility
name it shortcut.bat

@echo off

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

add to script:

call shortcut.bat
0
 

Author Comment

by:Techno-Man-uk
Comment Utility
that doesn't seem to work
0
 
LVL 67

Assisted Solution

by:sirbounty
sirbounty earned 500 total points
Comment Utility
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
 
LVL 67

Expert Comment

by:sirbounty
Comment Utility
Glad I could help - thanx for the grade! :^)
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
A short article about a problem I had getting the GPS LocationListener working.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

762 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now