Batch file - S: /DELETE

I use a cloud service that backs up all my data but it does not support networked drives.  

They provide a work around:

net use S: /DELETE
net use S: "\\<device_ip_address>\<share_name>" "<password>" /USER:"<username>" >>C:\tmp\mount.log

Open in new window


Looking at the  Net Use on TechNet - and I am thinking that this is going to want to create an S: drive, but to make sure that the S drive is not being used, it is deleted first?  

Just want to make sure I am understanding this before I use it

Thanks!
LVL 29
coreybryantAsked:
Who is Participating?
 
oBdACommented:
Two additional notes, just in case:

* You might want to add a "/persistent:no" to the "net use"; otherwise Windows might prompt you for the password on each logon, because it will try to reconnect the drive - unless you want to be prompted, of course; then you should add "/persistent:yes":
net use S: /DELETE
net use S: "\\<device_ip_address>\<share_name>" "<password>" /USER:"<username>" /PERSISTENT:NO >>C:\tmp\mount.log

Open in new window


* If you don't feel like saving your password in the batch script, you can replace the "<Password>" with a single "*" (without quotes).
Here's a script that prompts you even with the log file activated; note that there will be no console echo, not even asterisks:
@echo off
setlocal
set CloudShare=\\<device_ip_address>\<share_name>
net use S: /DELETE >NUL 2>&1
echo Type the password for '%CloudShare%':
net use S: "%CloudShare%" * /USER:"<username>" /PERSISTENT:NO >>C:\tmp\mount.log

Open in new window

0
 
KimputerCommented:
It's correct, the /delete is not totally necessary, but just to make sure you start "clean" (less error prone if you do it this way).
0
 
oBdACommented:
Yes, that's what will happen; net use S: /delete does not actually delete anything, it just removes any other share mapped to this drive letter.
To avoid the error message that appears when no drive is mapped to S you can simply use
net use S: /DELETE >NUL 2>&1

Open in new window

0
 
Lee W, MVPTechnology and Business Process AdvisorCommented:
That COULD be a WASTE of time.  If it's works by drive letter, fine, but there are ways to enumerating local disks and a drive letter does not guaranteed it's viewed as local.  Your best option is a backup solution that works or installing this one on the system providing the "S" drive.
0
 
coreybryantAuthor Commented:
Thanks - Follow up question coming now...
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.