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
759 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
Comment Utility
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
Comment Utility
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
Microservice architecture adoption brings many advantages, but can add intricacy. Selecting the right orchestration tool is most important for business specific needs.
This tutorial will walk an individual through the process of installing the necessary services and then configuring a Windows Server 2012 system as an iSCSI target. To install the necessary roles, go to Server Manager, and select Add Roles and Featu…
This tutorial will show how to configure a single USB drive with a separate folder for each day of the week. This will allow each of the backups to be kept separate preventing the previous day’s backup from being overwritten. The USB drive must be s…

772 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

10 Experts available now in Live!

Get 1:1 Help Now