473,396 Members | 2,098 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Run Regedit from Access form

I want to run regedit and write a key from an event in a form in a more
generic manner than the way I have done it here which is:

RunReg = Shell("regedit.exe /s I:\APPFolder\SQLfix.reg", 0)

The Access Application that I am running it from is in the folder
I:\AppFolder.

I am thinking something like this, but I am a bit unsure here if the
inverted commas are right.

RunReg = Shell("regedit.exe /s " & CurrentProject.Path & "\SQLfix.reg", 0)

I am unable to test this here. Can someone please comment on the quotation
marks in the generic version?

dixie
Nov 13 '05 #1
6 4727
The quotation marks appear to be good as long as there are no spaces in the
path or file name. If there are, it may need to look more like:

RunReg = Shell("regedit.exe /s """ & CurrentProject.Path & "\SQLfix.reg""",
0)

To put quotes around the Path\FileName. Shell sometimes gets picky about
extra quotes in the command line, so you'll need to test this with the file
placed in a folder that has a space in its name. Assuming Shell doesn't balk
at the extra quotes, they should work whether or not there is a space in the
Path\FileName.

--
Wayne Morgan
MS Access MVP
"dixie" <di***@dogmail.com> wrote in message
news:42********@duster.adelaide.on.net...
I want to run regedit and write a key from an event in a form in a more
generic manner than the way I have done it here which is:

RunReg = Shell("regedit.exe /s I:\APPFolder\SQLfix.reg", 0)

The Access Application that I am running it from is in the folder
I:\AppFolder.

I am thinking something like this, but I am a bit unsure here if the
inverted commas are right.

RunReg = Shell("regedit.exe /s " & CurrentProject.Path & "\SQLfix.reg", 0)

I am unable to test this here. Can someone please comment on the
quotation marks in the generic version?

dixie

Nov 13 '05 #2
Ah, thanks Wayne, that is what I thought. I tried putting two lots of
double quotation marks in but it would not accept it. I need it generic
enough to deal with spaces as I have not control over what users have called
their folders. What I needed was 3 sets of quotation marks - I've always
had difficulties working out how many and why.

dixie

"Wayne Morgan" <co***************************@hotmail.com> wrote in message
news:zs*******************@newssvr30.news.prodigy. com...
The quotation marks appear to be good as long as there are no spaces in
the path or file name. If there are, it may need to look more like:

RunReg = Shell("regedit.exe /s """ & CurrentProject.Path &
"\SQLfix.reg""", 0)

To put quotes around the Path\FileName. Shell sometimes gets picky about
extra quotes in the command line, so you'll need to test this with the
file placed in a folder that has a space in its name. Assuming Shell
doesn't balk at the extra quotes, they should work whether or not there is
a space in the Path\FileName.

--
Wayne Morgan
MS Access MVP
"dixie" <di***@dogmail.com> wrote in message
news:42********@duster.adelaide.on.net...
I want to run regedit and write a key from an event in a form in a more
generic manner than the way I have done it here which is:

RunReg = Shell("regedit.exe /s I:\APPFolder\SQLfix.reg", 0)

The Access Application that I am running it from is in the folder
I:\AppFolder.

I am thinking something like this, but I am a bit unsure here if the
inverted commas are right.

RunReg = Shell("regedit.exe /s " & CurrentProject.Path & "\SQLfix.reg",
0)

I am unable to test this here. Can someone please comment on the
quotation marks in the generic version?

dixie


Nov 13 '05 #3
The reason for 3 is because in order to include the delimiter, in this case
a quote, in the string that is being delimited, you have to double them up.
There has to be a way to tell VBA that you don't intend for THAT quote to be
a delimiter.

Example:
"""", this is a string with a quote as the only character in the output (").
The outside quotes are the delimiters. The double quotes in the middle tell
VBA that this one is to be treated literally.

--
Wayne Morgan
MS Access MVP
"dixie" <di***@dogmail.com> wrote in message
news:42********@duster.adelaide.on.net...
Ah, thanks Wayne, that is what I thought. I tried putting two lots of
double quotation marks in but it would not accept it. I need it generic
enough to deal with spaces as I have not control over what users have
called their folders. What I needed was 3 sets of quotation marks - I've
always had difficulties working out how many and why.

Nov 13 '05 #4
Wayne, sorry, but I still don't get it.

RunReg = Shell("regedit.exe /s """ & CurrentProject.Path & "\SQLfix.reg""",
0)

Why is the triple qoute around the 2nd and 4th instances and not the 1st and
3rd instances of quotes. It makes more sense to me to have them around all
of them?

dixie

"Wayne Morgan" <co***************************@hotmail.com> wrote in message
news:fn*****************@newssvr12.news.prodigy.co m...
The reason for 3 is because in order to include the delimiter, in this
case a quote, in the string that is being delimited, you have to double
them up. There has to be a way to tell VBA that you don't intend for THAT
quote to be a delimiter.

Example:
"""", this is a string with a quote as the only character in the output
("). The outside quotes are the delimiters. The double quotes in the
middle tell VBA that this one is to be treated literally.

--
Wayne Morgan
MS Access MVP
"dixie" <di***@dogmail.com> wrote in message
news:42********@duster.adelaide.on.net...
Ah, thanks Wayne, that is what I thought. I tried putting two lots of
double quotation marks in but it would not accept it. I need it generic
enough to deal with spaces as I have not control over what users have
called their folders. What I needed was 3 sets of quotation marks - I've
always had difficulties working out how many and why.


Nov 13 '05 #5
Anytime you have multiple quotes in a row, each pair ("") translates to ".
In what Wayen gave you, the first part "regedit.exe /s """ equates to the
string regedit.exe /s ": the double quotes translate to a quote, and you've
got the whole thing within quotes. Similarly, the final part "\SQLfix.reg"""
translates to the string \SQLfix.reg" In other words, if CurrentProject.Path
is, say, C:\My Application, you'll end up with the string

regedit.exe /s "C:\My Application\SQLfix.reg"
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

"dixie" <di***@dogmail.com> wrote in message
news:42********@duster.adelaide.on.net...
Wayne, sorry, but I still don't get it.

RunReg = Shell("regedit.exe /s """ & CurrentProject.Path &
"\SQLfix.reg""",
0)

Why is the triple qoute around the 2nd and 4th instances and not the 1st
and 3rd instances of quotes. It makes more sense to me to have them
around all of them?

dixie

"Wayne Morgan" <co***************************@hotmail.com> wrote in
message news:fn*****************@newssvr12.news.prodigy.co m...
The reason for 3 is because in order to include the delimiter, in this
case a quote, in the string that is being delimited, you have to double
them up. There has to be a way to tell VBA that you don't intend for THAT
quote to be a delimiter.

Example:
"""", this is a string with a quote as the only character in the output
("). The outside quotes are the delimiters. The double quotes in the
middle tell VBA that this one is to be treated literally.

--
Wayne Morgan
MS Access MVP
"dixie" <di***@dogmail.com> wrote in message
news:42********@duster.adelaide.on.net...
Ah, thanks Wayne, that is what I thought. I tried putting two lots of
double quotation marks in but it would not accept it. I need it generic
enough to deal with spaces as I have not control over what users have
called their folders. What I needed was 3 sets of quotation marks -
I've always had difficulties working out how many and why.



Nov 13 '05 #6
Dixie,

Another way to look at it would be to use a mix of single and double quotes.
If you change
RunReg = Shell("regedit.exe /s """ & CurrentProject.Path &
"\SQLfix.reg""",
0)


to

RunReg = Shell("regedit.exe /s '" & CurrentProject.Path & "\SQLfix.reg'", 0)

would it make more sense to you? This would put a single quote around the
path. You have to delimit the string with quotes, but when it gets passed
VBA removes the quotes, leaving (using C:\Folder for the path)

regedit.exe /s 'C:\Folder\SQLfix.reg'

In most cases, this is acceptable, but there are some things that don't like
the single quotes. When you run across one of those, you need to find a way
to "force" the double quotes in (since Access is using them to find the
beginning and end of the string(s) you can't just put them in as normal,
there has to be a different method to distinguish between the two -
delimiter or literal quote in the string). One good example of when this is
needed is when doing a search of a Last Name field. If you place single
quotes around the field, then names such as O'Hare will cause your code to
crash because the single quote in the name causes a problem with the single
quotes around the name.

The above could also be written this way to get the double quote in instead
of using a single quote.

RunReg = Shell("regedit.exe /s " & Chr(34) & CurrentProject.Path &
"\SQLfix.reg" & Chr(34), 0)

Using the double quote is easier to type than Chr(34), but it can be harder
to read and is definitely harder to count to make sure that you have them
all matched up.

I would suggest playing with this in the Immediate Window and see what gets
returned.

Example:
?"This is a test string"
This is a test string

?"This is "" a test string"
This is " a test string

This will show you what is actually being passed once VBA removes the
delimiter quotes. The delimiter quotes tell VBA that this is a string, once
they've done that, they've done their job and aren't needed any longer. So,
they're removed. If they weren't and you assigned the value to a textbox,
the text would still have the quotes around it in the textbox instead of
just the text being there.

--
Wayne Morgan
MS Access MVP
Nov 13 '05 #7

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

Similar topics

6
by: the_bass_man | last post by:
I need to be able to delete the value of something in my regedit using vb. Does any1 know how i would go about this. Thanks Ste
1
by: Option^Explicit | last post by:
I have seen some apps that are able to control/open regedit and highlight keys throughout the tree and open at a specified subkey. Something like a "Goto" function thats opens regedit at exactley...
20
by: Olav.NET | last post by:
I am a .NET/C++ developer who is supposed to do some work with Access. I do not know much about it except for the DB part. Questions: *1* I am looking for INTENSIVE books to get quickly up to...
7
by: German | last post by:
How Can I recover data from REgEDIT since Visual C++ 6.0 ? Thanks in advanced
1
by: OgaW | last post by:
Hi, How exactly does the regedit registry work in windows? How can we make use of them in our application? How the hacker can exploit the registry setting to plant hidden virus down there?...
49
by: indiauday | last post by:
Hello friends, I am new user to this community. My problem is when I try to open registry editor by start> run > regedit, it displays this message. "Registry...
22
epots9
by: epots9 | last post by:
I forgot how to fix this, so i was wondering: how can i get my computer (WIN XP Media Center SP2) to auto select my user account at the logon screen? I only have one account setup with a password....
3
by: RMDan | last post by:
I want a way to disable regedit, but enabling it with out using group policies? Im trying to make my computer safer and want to set up a set of files to enable/disable cmd(i ave bin doing it with...
0
by: adas1173 | last post by:
Hi, I am not able to open the regedit by typing "regedit" in Run. There is no error message being displayed. It simply doesn't run. Searched about it online. Looks like a virus or spyware can...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
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...
0
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...
0
agi2029
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,...

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.