473,851 Members | 2,102 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Shell Function Parameter with Spaces

Hi Friends

I want to launch notepad with a specific file on a
command click event. So I was using the "Shell" function
from VB on a command click event.For ex:

Shell "Notepad.ex e C:\Program
Files\Test.txt" ,VbNormalFocus

But here is the problem in the space of the "Program
Files" folder, ie, "Program[SPACE]Files". The Shell
function not reading any character after the SPACE.

So HOW CAN I Launch my programs which has a SPACE in the
PATH parameter ???

Nov 20 '05 #1
3 11839
* "Mr Utkal Ranjan" <ut*****@hotmai l.com> scripsit:
I want to launch notepad with a specific file on a
command click event. So I was using the "Shell" function
from VB on a command click event.For ex:

Shell "Notepad.ex e C:\Program
Files\Test.txt" ,VbNormalFocus

But here is the problem in the space of the "Program
Files" folder, ie, "Program[SPACE]Files". The Shell
function not reading any character after the SPACE.

So HOW CAN I Launch my programs which has a SPACE in the
PATH parameter ???

Try 'System.Diagnos tics.Process.St art'.

Herfried K. Wagner [MVP]
Nov 20 '05 #2
> Shell "Notepad.ex e C:\Program
Files\Test.txt" ,VbNormalFocus

But here is the problem in the space of the "Program
Files" folder, ie, "Program[SPACE]Files". The Shell
function not reading any character after the SPACE.

Mr. Wagner's response is probably a better way, but here's the rundown on
the spaces:

When you called shell, you passed it a command line that is interpreted by
the operating system:

Notepad.exe C:\Program Files\Test.txt

According to the way the operating system parses command lines, you have
specified 3 tokens:

1. Notepad.exe
2. C:\Program
3. Files\Test.txt

The operating system recognises the first as a program, finds it in the
path, and executes it, passing the other two tokens as two command line
parameters. Notepad thinks that "c:\program " is the name of the file you
want to open.

To prevent this, any file system references can be enclosed in double quotes
so that the operating system doesn't misinterpret the meaning of the embeded
spaces, like this (you can actually try this in a Start -> Run box):

Notepad.exe "C:\Program Files\Test.txt"

The way you would issue your shell statement to include the quotes as part
of the string is to use two double quotes for each double quote that you
want inside the string:

Dim s As String
s = "Notepad.ex e ""C:\Progra m Files\Test.txt" ""
MessageBox.Show (s) 'Note the way the quotes are embedded
Shell(s, AppWinStyle.Nor malFocus)

This quote technique works anywhere in Windows where the operating system or
a [well written] program expects a path or filename.
Peace & happy computing,

Mike Labosh, MCSD MCT
Owner, vbSensei.Com
"Escriba coda ergo sum." -- vbSensei
Nov 20 '05 #3
Thanx yaaar

Its working .....

Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: Will Seay | last post by:
At the end of this message I've pasted a script we're trying to modify slightly. I don't believe it is VBscript or javascript but these are the closest groups I could find with my limited programming knowledge. Basically, we are trying to add a few lines to this script that will execute a few shell commands (see comments at the very end of the code). We think this may be ActionScript2 but aren't sure. If you can offer any help, or know...
by: Nick Craig-Wood | last post by:
I'm trying to avoid using shell metacharacters in os.popen in a portable fashion. os.popen() only seems to take a string as the command which would need tricky quoting. os.popen2() can take a string or a list - the relevant code in Unix python (in popen2.py) being... def _run_child(self, cmd):
by: Isaac | last post by:
Hi mates I want to know a simple program of return array from function ? Do I need to use pointer to return the address of the first element in an array. Isaac
by: zhiwei wang | last post by:
I remember that there is a function that could invoke shell command such as "rm" "cp", directly in .c file. But I could not recall its name, and I googled with nothing meaningful. I vaguely remember it is like: foo("cp file1 file2"); it is that simple, but cant remember. Could anyone here give me a clue?
by: Robert E. Flaherty | last post by:
I am using System.Data.OracleClient (Oracle Provider for OLE DB in an ASP.NET 1.1 app. I am evoking a stored procedure with a number of input parameters and two output parameters, both declared ParametrerDirection.InputOutput. The first of these two output parameters is an integer value. It is the status of the running of the stored procedure. It is working fine. The second parameter is designed to return a message from...
by: Ken Miller | last post by:
Hi all, I'm very new to vb.net, and was trying to write a wrapper for a command line utility, the problem being the parameter to be called to it is a path, and will generally have spaces in it. I've tried various things, using multiple "'s, Chr$(34)s and its making me mad now :) TextBox1 is the path that I'm sending to the cmd. Really all I want is to put a pair of quotes around the actual path, so that the data in TextBox1 becomes...
by: Dave G | last post by:
I know this is an old favourite but I can't find a simple answer to a simple question. I'm trying to run this: shell("c:\program files\pkware\pkzipc\pkzipc.exe -ext " & myPath & myZIPFile & " " & myPath) I want to unzip a file who's path name is defined by the variable myPath and who's file name is defined by the variable myZIPFile, and
by: Mike | last post by:
Am trying to open a Microsoft Word .doc file using Access 2000 with Shell function (on Windows XP Operating system) Here is the code : Shell "C:\Program Files\Microsoft Office\Office\Winword.exe O:\Patients Charts\mstest.doc" As soon as I try to open the same file on the O: drive (a directly connected server) , I get the following error message:"The document
by: =?ISO-8859-2?Q?Gregor_Kova=E8?= | last post by:
Hi! Is it possible to use parameter markers like this: 1.) SELECT * FROM TABLE1 WHERE FIELD1 LIKE '%?%' If I now set parameter 1 to '' (empty string) I don't get any rows back, but if I run: 2.) SELECT * FROM TABLE1 WHERE FIELD1 LIKE '%%' I get back data I expect.
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.