PC Review


Reply
Thread Tools Rate Thread

handling spaces in file names

 
 
David M...
Guest
Posts: n/a
 
      7th Aug 2003
I am using VBScript to write some system management
scripts on XP.

I am having problems when a full path filename contains
spaces:

e.g. I define a constant string as
Const defragcmd = "C:\Program Files\Norton
SystemWorks\Speed Disk\sdntc.exe"

Then try to run it using WSH:
Dim WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run defragcmd , 1, true

This fails as script reports can not find specified file.

I get the same error with

WshShell.Run """defragcmd""" , 1, true

How can I pass the filename containing spaces to WSH?

What I am trying to do is run the defragcmd on several
disks so the first part of the cmd is the constant then I
want to add the options before calling WSH e.g.

cmd =defragcmd & " -drive=" & osdisk & " -auto"

But I am stuck with that space in the full path name. Any
ways round this?

Thanks

David
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Open Excel file get error with file names that have spaces in the Kozmo Microsoft Excel Setup 7 1st Feb 2011 04:34 PM
Finding file names with spaces in them Charles Lavin Windows XP General 12 10th Oct 2005 02:47 AM
SP2, IE6 and Spaces in File Names Rubber Chicken Windows XP General 1 1st Nov 2004 06:22 PM
using underscores in file names instead of spaces Jason Microsoft Excel Misc 2 7th Apr 2004 10:38 PM
File names with spaces - hyperlinks Chris Healy Microsoft Outlook 3 15th Mar 2004 12:34 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:44 AM.