1.

Solve : Spaces in directory names?

Answer»

I'm new to programming, and I require assistance with a minor problem.

what can I use to form a space in a directory name so that cmd will ACCEPT it.

for example:

@start C:\Program Files\Microsoft Office\OFFICE11\WINWORD.exe

But when I attempt to run the command in cmd it says:

Windows cannot find "C:\Program" etc..

What do I use in replace of the space?

Thanks in advance.The best way is probably putting quotes around the path, like:
Code: [Select]@start "C:\Program Files\Microsoft Office\OFFICE11\WINWORD.exe"
You could ALSO use short 8.3 names like:
@start C:\Progra~1\Micros~1\OFFICE11\WINWORD.exe

The CD command does takes spaces, so you could do:
Code: [Select]cd /d C:\Program Files\Microsoft Office\OFFICE11
start WINWORD.exeThanks a bunch I'll try it now.

Also another thing I need to know, what command would I need to tell the computer to shutdown, log off etc?The shutdown code.
-t = time until shutdown (use two or more digits such as 05 or 00 or 200)
-f = forces applications to close
-c = shows a comment while shutting down (i.e. "You are now shutting down. Save your work")

-s = shutdown
-r = restart
-l = log-off


Code: [Select]shutdown -s -t 30 -c "You are now shutting down. Save your work." -f
Note that if you are in a batch file, use shutdown.exe instead of shutdown.Quote from: Dark Blade on May 29, 2007, 12:45:11 AM

Note that if you are in a batch file, use shutdown.exe instead of shutdown.

Using the .exe extension is optional, whether an executable is in the current folder, or on the PATH. The only reason to explicitly add the extension would be if you had a different executable eg shutdown.com shoutdown.bat or shutdown.cmd in either of those places. (Bad practice!) If shutdown.exe is where it should be, ie C:\WINDOWS\system32, then shutdown or shutdown.exe will find it. Or am I missing something?

Code: [Select]c:\>shutdown /?
USAGE: shutdown [-i | -l | -s | -r | -a] [-f] [-m \\computername] [-t xx] [-c "comment"] [-d up:xx:yy]

No args Display this message (same as -?)
-i Display GUI interface, must be the first option
-l Log off (cannot be used with -m option)
-s Shutdown the computer
-r Shutdown and restart the computer
-a Abort a system shutdown
-m \\computername Remote computer to shutdown/restart/abort
-t xx Set timeout for shutdown to xx seconds
-c "comment" Shutdown comment (maximum of 127 characters)
-f Forces running applications to close without warning
-d [u][p]:xx:yy The reason code for the shutdown
u is the user code
p is a planned shutdown code
xx is the major reason code (positive integer less than 256)
yy is the minor reason code (positive integer less than 65536)

c:\>shutdown.exe /?
Usage: shutdown.exe [-i | -l | -s | -r | -a] [-f] [-m \\computername] [-t xx] [-c "comment"] [-d up:xx:yy]

No args Display this message (same as -?)
-i Display GUI interface, must be the first option
-l Log off (cannot be used with -m option)
-s Shutdown the computer
-r Shutdown and restart the computer
-a Abort a system shutdown
-m \\computername Remote computer to shutdown/restart/abort
-t xx Set timeout for shutdown to xx seconds
-c "comment" Shutdown comment (maximum of 127 characters)
-f Forces running applications to close without warning
-d [u][p]:xx:yy The reason code for the shutdown
u is the user code
p is a planned shutdown code
xx is the major reason code (positive integer less than 256)
yy is the minor reason code (positive integer less than 65536)

c:\>echo shutdown /? > ss.bat

c:\>echo shutdown.exe /? >> ss.bat

c:\>ss

c:\>shutdown /?
Usage: shutdown [-i | -l | -s | -r | -a] [-f] [-m \\computername] [-t xx] [-c "comment"] [-d up:xx:yy]

No args Display this message (same as -?)
-i Display GUI interface, must be the first option
-l Log off (cannot be used with -m option)
-s Shutdown the computer
-r Shutdown and restart the computer
-a Abort a system shutdown
-m \\computername Remote computer to shutdown/restart/abort
-t xx Set timeout for shutdown to xx seconds
-c "comment" Shutdown comment (maximum of 127 characters)
-f Forces running applications to close without warning
-d [u][p]:xx:yy The reason code for the shutdown
u is the user code
p is a planned shutdown code
xx is the major reason code (positive integer less than 256)
yy is the minor reason code (positive integer less than 65536)

c:\>shutdown.exe /?
Usage: shutdown.exe [-i | -l | -s | -r | -a] [-f] [-m \\computername] [-t xx] [-c "comment"] [-d up:xx:yy]

No args Display this message (same as -?)
-i Display GUI interface, must be the first option
-l Log off (cannot be used with -m option)
-s Shutdown the computer
-r Shutdown and restart the computer
-a Abort a system shutdown
-m \\computername Remote computer to shutdown/restart/abort
-t xx Set timeout for shutdown to xx seconds
-c "comment" Shutdown comment (maximum of 127 characters)
-f Forces running applications to close without warning
-d [u][p]:xx:yy The reason code for the shutdown
u is the user code
p is a planned shutdown code
xx is the major reason code (positive integer less than 256)
yy is the minor reason code (positive integer less than 65536)

c:\>

c:\>


Oh, my mistake.

I thought I read somewhere that you had to run shutdown as a program in batch files, because you can't use the shutdown command in batch.

But I guess I must've read wrong.Thanks a lot you guys, you've been a mountain of help.

Now I just need to know one thing (I know I'm probably getting annoying now)

But what would I need to input to tell it OPEN a browser on a certain website?"C:\Program Files\Internet Explorer\IEXPLORE.EXE" "http://www/google.com"
Quote from: Millenion on May 29, 2007, 02:09:08 PM
Thanks a lot you guys, you've been a mountain of help.

Now I just need to know one thing (I know I'm probably getting annoying now)

But what would I need to input to tell it open a browser on a certain website?
you can just do
Code: [Select]c:\> start "www.google.com"
Actually, you wouldn't need the quotes because all websites are one WORD (they use underscores for spaces).

So,
Code: [Select]start www.google.com


Discussion

No Comment Found