Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

How do I use spaces in batch files? Is there a way to make strings in batch files as one? Like in .NET example "Look_at_me"

Posted on 2008-06-10
4
765 Views
Last Modified: 2008-07-23
As you can see in the batch file below, the password has a space between it, are there any ways of making the CMD reading this as one string? Like in .NET example we use "test !"

how can i do this in batch files?

same goes for the folder D:\sqlserver data

this seems to be giving errors to the CMD - problems with spaces. How can I make the CMD read this as one?

thanks for the help guys, appreciated!
NET USE X:\\0.0.0.0\C$ Password !01 /USER:Administrator /PERSISTENT:NO
 
MOVE D:\sqlserver data\Backup\one\*.* X:\BACKUP\DB
 
MOVE D:\sqlserver data\Backup\two\*.* X:\BACKUP\DB
 
MOVE D:\sqlserver data\Backup\three\*.* X:\BACKUP\DB
 
pause

Open in new window

0
Comment
Question by:Mezillinu
4 Comments
 
LVL 26

Accepted Solution

by:
farhankazi earned 500 total points
ID: 21749055
You can enclose path and password in double quotes " " (like you do in .Net).
Like:

NET USE X:\\0.0.0.0\C$ /USER:Administrator "Your password here!" /PERSISTENT:NO
 
MOVE "D:\sqlserver data\Backup\one\*.*" X:\BACKUP\DB
 
MOVE "D:\sqlserver data\Backup\two\*.*" X:\BACKUP\DB
 
MOVE "D:\sqlserver data\Backup\three\*.*" X:\BACKUP\DB
 
pause

Open in new window

0
 
LVL 1

Expert Comment

by:gavbell
ID: 21749065
Hi Mezillinu,

All you need to do is put the line with spaces have quotes either sides for example.

MOVE "D:\sqlserver data\Backup\one\*.*"  X:\BACKUP\DB

Hope this helps.

Gav
0

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

Storage devices are generally used to save the data or sometime transfer the data from one computer system to another system. However, sometimes user accidentally erased their important data from the Storage devices. Users have to know how data reco…
VM backups can be lost due to a number of reasons: accidental backup deletion, backup file corruption, disk failure, lost or stolen hardware, malicious attack, or due to some other undesired and unpredicted event. Thus, having more than one copy of …
This tutorial will walk an individual through the steps necessary to enable the VMware\Hyper-V licensed feature of Backup Exec 2012. In addition, how to add a VMware server and configure a backup job. The first step is to acquire the necessary licen…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

839 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