Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Using variable (which includes spaces) in vbscript shell.run

09 Jun 2019   #1
ColDon

Windows 7 Home Premium 64 bit
 
 
Using variable (which includes spaces) in vbscript shell.run

Unable to find anything specific for this other than spaces in actual file paths. I know I can deal with this by using the actual path and file name enclosed by 3 quotes (inverted commas) but this would have to be changed each time I ran the script. Because thay would be very tedious I need the path and file name to be in the 2 variables as they will be constantly changing

The path will be in var1 and the file name in var2 as follows:

Var1 = "C:\Specials\Blues And Twos\"
Var2 = "Luna Pic.jpg"

Here is the relevent part of my script.

Set shell = CreateObject("WScript.Shell")
shell.Run Var1 & Var2, 1, false

This is no problem running this if there are no spaces iin variables Var1 and Var2. Unfortunately there are in both so how can I get this to run. I know the answer lies in the placing of the quotes so I've tried various combinations but without success.

Any help would be gratefully received.


My System SpecsSystem Spec
.
09 Jun 2019   #2
samuria

win 8 32 bit
 
 

Welcome to the forurm it doesnt allow spaces but Itry to avoid spaces in names because of these kind of issues. One thing you can try, which is how you get around names with spaces in a vbscript is using triple quotes (""") to open and close your statement. Example: cscript.exe """%deployroot%\Applications\my appli with space\myScript.vbs"""
My System SpecsSystem Spec
10 Jun 2019   #3
ColDon

Windows 7 Home Premium 64 bit
 
 

Thanks for your reply Samuria but as I said it will not accept the 3 quotes as it treats a variable as a file path+name hence the rejection under "cannot find file". It does not recognise that the variable contains that information.
My System SpecsSystem Spec
.

Reply

 Using variable (which includes spaces) in vbscript shell.run




Thread Tools




Similar help and support threads
Thread Forum
Registry: differences between Shell Folders and User Shell Folders?
Please consider these two keys: What is the main difference between these? Say, I've changed first the keys under Shell Folders and then under User Shell Folders. It was only until I'd changed those under User Shell Folders (after restarting the machine) did the changes take place.
General Discussion
VBScript error
Hello, I have read and followed the instructions on the sticky but still having the same issue. Here is the cmd line response that i get: HKEY_CLASSES_ROOT\CLSID\{B54F3741-5B07-11cf-A4B0-00AA004A55E8}\InprocServer32 (Default) REG_SZ C:\Windows\system32\vbscript.dll ...
Windows Updates & Activation
Bottom Shell / Top Shell
I just downloaded a new theme and there is two copies of the theme in their own folders one labeled "Theme name Bottom Shell" and the other labeled "Theme name Top Shell" Can someone enlighten me as to what the difference would be between the two as i really do not know :huh: I was going to...
Themes and Styles
can't find vbscript...
trying to run some vbscripts and receive error 'can't find script engine "VBScript" for script xxxxx. tried doing regsvr32 on vbscript.dll and received OK msg, but did not do any good. also ran regsvr32 for 'jscript.dll', but again did not work... appreciate help to enable vbscript engine. i...
General Discussion
VBScript or powershell
i m a beginner and i want to learn a scripting language. which should b better vbscript or powershell?
Software


Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 19:49.
Twitter Facebook