473,657 Members | 2,401 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Getting rid of hard coded path

I have been running some code from a form's on open event to run regedit if
a registry key does not exist in the registry. It has been working fine,
but I have had the path to the registry fix file hard coded into the VBA
like this.

RunReg = Shell("regedit. exe /s F:\MyFolder\SQL fix.reg", 0)

Now I wish to make this more generic and allow it to run from any path.

I have tried to use CurrentProjectP ath like this.

RunReg = Shell("regedit. exe /s" & CurrentProjectP ath & "\SQLfix.re g", 0)

When I do this, I get a 'compile error variable not defined :
CurrentProjectP ath'.

I realise this probably means I should have dimmed the CurrentProjectP ath,
but I am unsure as what to dim it as. Am I one the right track and if so,
what is my dim statement?

dixie

Nov 13 '05 #1
7 2210
Dimming it as a string should do OK...

--
Nick Coe (UK)
AccHelp v1.01 Access Application Help File Builder
http://www.alphacos.co.uk/
Download Free Copy
----

In news:41******** @duster.adelaid e.on.net,
dixie typed:
I have been running some code from a form's on open event
to run
regedit if a registry key does not exist in the registry.
It has
been working fine, but I have had the path to the registry
fix file
hard coded into the VBA like this.

RunReg = Shell("regedit. exe /s F:\MyFolder\SQL fix.reg", 0)

Now I wish to make this more generic and allow it to run
from any
path.
I have tried to use CurrentProjectP ath like this.

RunReg = Shell("regedit. exe /s" & CurrentProjectP ath &
"\SQLfix.re g",
0)
When I do this, I get a 'compile error variable not
defined :
CurrentProjectP ath'.

I realise this probably means I should have dimmed the
CurrentProjectP ath, but I am unsure as what to dim it as.
Am I one
the right track and if so, what is my dim statement?

dixie

Nov 13 '05 #2
I believe you are looking for CurrentProject. Path, not CurrentProjectP ath.

On Mon, 27 Dec 2004 07:14:12 +1100, "dixie" <di***@dogmail. com> wrote:
I have been running some code from a form's on open event to run regedit if
a registry key does not exist in the registry. It has been working fine,
but I have had the path to the registry fix file hard coded into the VBA
like this.

RunReg = Shell("regedit. exe /s F:\MyFolder\SQL fix.reg", 0)

Now I wish to make this more generic and allow it to run from any path.

I have tried to use CurrentProjectP ath like this.

RunReg = Shell("regedit. exe /s" & CurrentProjectP ath & "\SQLfix.re g", 0)

When I do this, I get a 'compile error variable not defined :
CurrentProject Path'.

I realise this probably means I should have dimmed the CurrentProjectP ath,
but I am unsure as what to dim it as. Am I one the right track and if so,
what is my dim statement?

dixie


Nov 13 '05 #3
You're right Steve, that is what I had in the code originally and somehow it
fell out between there and adding it to the message.

You think it should work though I presume then? Its just that I am not in a
position to test it as the .reg file is for Office 2003, which I do not
have.

dixie

"Steve Jorgensen" <no****@nospam. nospam> wrote in message
news:fj******** *************** *********@4ax.c om...
I believe you are looking for CurrentProject. Path, not CurrentProjectP ath.

On Mon, 27 Dec 2004 07:14:12 +1100, "dixie" <di***@dogmail. com> wrote:
I have been running some code from a form's on open event to run regedit
if
a registry key does not exist in the registry. It has been working fine,
but I have had the path to the registry fix file hard coded into the VBA
like this.

RunReg = Shell("regedit. exe /s F:\MyFolder\SQL fix.reg", 0)

Now I wish to make this more generic and allow it to run from any path.

I have tried to use CurrentProjectP ath like this.

RunReg = Shell("regedit. exe /s" & CurrentProjectP ath & "\SQLfix.re g", 0)

When I do this, I get a 'compile error variable not defined :
CurrentProjec tPath'.

I realise this probably means I should have dimmed the CurrentProjectP ath,
but I am unsure as what to dim it as. Am I one the right track and if so,
what is my dim statement?

dixie

Nov 13 '05 #4
If it was working before with the hard coded path, it should work again with
the relative path using CurrentProject. Path. Still, I have a word for
untested code. The word is "broken".

You should try out the technique using a dummy .reg file, just to make sure
it's all OK. You can hand-build a .reg file by looking at the format for any
other .reg file, and just have it create some random, harmless key.

On Mon, 27 Dec 2004 13:23:47 +1100, "dixie" <di***@dogmail. com> wrote:
You're right Steve, that is what I had in the code originally and somehow it
fell out between there and adding it to the message.

You think it should work though I presume then? Its just that I am not in a
position to test it as the .reg file is for Office 2003, which I do not
have.

dixie

"Steve Jorgensen" <no****@nospam. nospam> wrote in message
news:fj******* *************** **********@4ax. com...
I believe you are looking for CurrentProject. Path, not CurrentProjectP ath.

On Mon, 27 Dec 2004 07:14:12 +1100, "dixie" <di***@dogmail. com> wrote:
I have been running some code from a form's on open event to run regedit
if
a registry key does not exist in the registry. It has been working fine,
but I have had the path to the registry fix file hard coded into the VBA
like this.

RunReg = Shell("regedit. exe /s F:\MyFolder\SQL fix.reg", 0)

Now I wish to make this more generic and allow it to run from any path.

I have tried to use CurrentProjectP ath like this.

RunReg = Shell("regedit. exe /s" & CurrentProjectP ath & "\SQLfix.re g", 0)

When I do this, I get a 'compile error variable not defined :
CurrentProje ctPath'.

I realise this probably means I should have dimmed the CurrentProjectP ath,
but I am unsure as what to dim it as. Am I one the right track and if so,
what is my dim statement?

dixie


Nov 13 '05 #5
You were absolutely right Steve, if it is not tested it is broken! I have
made it run now and replacing the version with the hard coded path to the
..reg file with the CurrentProject. Path version does not work. No key is
written.

RunReg = Shell("regedit. exe /s F:\MyFolder\SQL fix.reg", 0) - This works.

RunReg = Shell("regedit. exe /s" & CurrentProject. Path & "\SQLfix.re g", 0) -
This does not work.

Now, what can I do to get a generic one that DOES work?

dixie

"Steve Jorgensen" <no****@nospam. nospam> wrote in message
news:dv******** *************** *********@4ax.c om...
If it was working before with the hard coded path, it should work again
with
the relative path using CurrentProject. Path. Still, I have a word for
untested code. The word is "broken".

You should try out the technique using a dummy .reg file, just to make
sure
it's all OK. You can hand-build a .reg file by looking at the format for
any
other .reg file, and just have it create some random, harmless key.

On Mon, 27 Dec 2004 13:23:47 +1100, "dixie" <di***@dogmail. com> wrote:
You're right Steve, that is what I had in the code originally and somehow
it
fell out between there and adding it to the message.

You think it should work though I presume then? Its just that I am not in
a
position to test it as the .reg file is for Office 2003, which I do not
have.

dixie

"Steve Jorgensen" <no****@nospam. nospam> wrote in message
news:fj****** *************** ***********@4ax .com...
I believe you are looking for CurrentProject. Path, not
CurrentProje ctPath.

On Mon, 27 Dec 2004 07:14:12 +1100, "dixie" <di***@dogmail. com> wrote:

I have been running some code from a form's on open event to run regedit
if
a registry key does not exist in the registry. It has been working
fine,
but I have had the path to the registry fix file hard coded into the VBA
like this.

RunReg = Shell("regedit. exe /s F:\MyFolder\SQL fix.reg", 0)

Now I wish to make this more generic and allow it to run from any path.

I have tried to use CurrentProjectP ath like this.

RunReg = Shell("regedit. exe /s" & CurrentProjectP ath & "\SQLfix.re g", 0)

When I do this, I get a 'compile error variable not defined :
CurrentProj ectPath'.

I realise this probably means I should have dimmed the
CurrentProj ectPath,
but I am unsure as what to dim it as. Am I one the right track and if
so,
what is my dim statement?

dixie

Nov 13 '05 #6
The first think I notice is that you do not have a space following the /s
before the close quote, so the dynamic string will not have a space there.
Also, I can't recall whether CurrentProject. Path includes a final "\" or not,
so you might want to print that from the debug window to see what it has.

On Mon, 27 Dec 2004 16:37:36 +1100, "dixie" <di***@dogmail. com> wrote:
You were absolutely right Steve, if it is not tested it is broken! I have
made it run now and replacing the version with the hard coded path to the
.reg file with the CurrentProject. Path version does not work. No key is
written.

RunReg = Shell("regedit. exe /s F:\MyFolder\SQL fix.reg", 0) - This works.

RunReg = Shell("regedit. exe /s" & CurrentProject. Path & "\SQLfix.re g", 0) -
This does not work.

Now, what can I do to get a generic one that DOES work?

dixie

"Steve Jorgensen" <no****@nospam. nospam> wrote in message
news:dv******* *************** **********@4ax. com...
If it was working before with the hard coded path, it should work again
with
the relative path using CurrentProject. Path. Still, I have a word for
untested code. The word is "broken".

You should try out the technique using a dummy .reg file, just to make
sure
it's all OK. You can hand-build a .reg file by looking at the format for
any
other .reg file, and just have it create some random, harmless key.

On Mon, 27 Dec 2004 13:23:47 +1100, "dixie" <di***@dogmail. com> wrote:
You're right Steve, that is what I had in the code originally and somehow
it
fell out between there and adding it to the message.

You think it should work though I presume then? Its just that I am not in
a
position to test it as the .reg file is for Office 2003, which I do not
have.

dixie

"Steve Jorgensen" <no****@nospam. nospam> wrote in message
news:fj***** *************** ************@4a x.com...
I believe you are looking for CurrentProject. Path, not
CurrentProj ectPath.

On Mon, 27 Dec 2004 07:14:12 +1100, "dixie" <di***@dogmail. com> wrote:

>I have been running some code from a form's on open event to run regedit
>if
>a registry key does not exist in the registry. It has been working
>fine,
>but I have had the path to the registry fix file hard coded into the VBA
>like this.
>
>RunReg = Shell("regedit. exe /s F:\MyFolder\SQL fix.reg", 0)
>
>Now I wish to make this more generic and allow it to run from any path.
>
>I have tried to use CurrentProjectP ath like this.
>
>RunReg = Shell("regedit. exe /s" & CurrentProjectP ath & "\SQLfix.re g", 0)
>
>When I do this, I get a 'compile error variable not defined :
>CurrentPro jectPath'.
>
>I realise this probably means I should have dimmed the
>CurrentPro jectPath,
>but I am unsure as what to dim it as. Am I one the right track and if
>so,
>what is my dim statement?
>
>dixie
>
>


Nov 13 '05 #7
Yes, that was it, just discovered it myself too. I needed RunReg =
Shell("regedit. exe /s " & CurrentProject. Path & "\SQLfix.re g", 0) with the
space after the /s as you said. The CurrentProject. Path does not include
the trailing backslash, and it needs to be where I had it.

Thanks for your words of wisdom about untested code. I would have just
bitten my tongue and put it in before you said that.

dixie

"Steve Jorgensen" <no****@nospam. nospam> wrote in message
news:lu******** *************** *********@4ax.c om...
The first think I notice is that you do not have a space following the /s
before the close quote, so the dynamic string will not have a space there.
Also, I can't recall whether CurrentProject. Path includes a final "\" or
not,
so you might want to print that from the debug window to see what it has.

On Mon, 27 Dec 2004 16:37:36 +1100, "dixie" <di***@dogmail. com> wrote:
You were absolutely right Steve, if it is not tested it is broken! I have
made it run now and replacing the version with the hard coded path to the
.reg file with the CurrentProject. Path version does not work. No key is
written.

RunReg = Shell("regedit. exe /s F:\MyFolder\SQL fix.reg", 0) - This works.

RunReg = Shell("regedit. exe /s" & CurrentProject. Path & "\SQLfix.re g",
0) -
This does not work.

Now, what can I do to get a generic one that DOES work?

dixie

"Steve Jorgensen" <no****@nospam. nospam> wrote in message
news:dv****** *************** ***********@4ax .com...
If it was working before with the hard coded path, it should work again
with
the relative path using CurrentProject. Path. Still, I have a word for
untested code. The word is "broken".

You should try out the technique using a dummy .reg file, just to make
sure
it's all OK. You can hand-build a .reg file by looking at the format
for
any
other .reg file, and just have it create some random, harmless key.

On Mon, 27 Dec 2004 13:23:47 +1100, "dixie" <di***@dogmail. com> wrote:

You're right Steve, that is what I had in the code originally and
somehow
it
fell out between there and adding it to the message.

You think it should work though I presume then? Its just that I am not
in
a
position to test it as the .reg file is for Office 2003, which I do not
have.

dixie

"Steve Jorgensen" <no****@nospam. nospam> wrote in message
news:fj**** *************** *************@4 ax.com...
>I believe you are looking for CurrentProject. Path, not
>CurrentPro jectPath.
>
> On Mon, 27 Dec 2004 07:14:12 +1100, "dixie" <di***@dogmail. com> wrote:
>
>>I have been running some code from a form's on open event to run
>>regedit
>>if
>>a registry key does not exist in the registry. It has been working
>>fine,
>>but I have had the path to the registry fix file hard coded into the
>>VBA
>>like this.
>>
>>RunReg = Shell("regedit. exe /s F:\MyFolder\SQL fix.reg", 0)
>>
>>Now I wish to make this more generic and allow it to run from any
>>path.
>>
>>I have tried to use CurrentProjectP ath like this.
>>
>>RunReg = Shell("regedit. exe /s" & CurrentProjectP ath & "\SQLfix.re g",
>>0)
>>
>>When I do this, I get a 'compile error variable not defined :
>>CurrentPr ojectPath'.
>>
>>I realise this probably means I should have dimmed the
>>CurrentPr ojectPath,
>>but I am unsure as what to dim it as. Am I one the right track and if
>>so,
>>what is my dim statement?
>>
>>dixie
>>
>>
>

Nov 13 '05 #8

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

Similar topics

1
2310
by: Carl Hilton | last post by:
Trying to get Windows AD LDAP working to recognize who is accessing the page... I have successfully grabbed the user credentials and passed them off to LDAP, but that required me to pass off a hard coded Userid and password. Since this server is on our corporate network. Is there a way to either: 1) Grab the userid/password of the client and use them to access the windows LDAP server withouth having to give out my own? or 2) Protect...
33
2351
by: Xah Lee | last post by:
The Harm of hard-wrapping Lines 20050222 Computing Folks of the industry: please spread the debunking of the truncating line business of the fucking unix-loving fuckheads, as outlines here: http://xahlee.org/UnixResource_dir/writ/truncate_line.html
6
1788
by: Water Cooler v2 | last post by:
How does one get the root of the ASP.NET application. For instance, my application is: http://localhost/MyApplication/login.aspx Today, it is on a test server, but when I move it to the production server, it would become something like: http://www.foobar.com/MyApplication/login.aspx
8
13515
by: Amit | last post by:
I have a master page and a content page but the stylesheet isnt getting applied like how it looks in visual studio design view. The master page is defined like this: <%@ Master Language="VB" CodeFile="MasterPage.master.vb" Inherits="MasterPage" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
1
5767
by: mikebian | last post by:
I created a db that houses info about pictures that were scanned into the PC. The pictures are stored on the file system. I have a form coded so that it shows thumbnails of the images, which are stored in a directory under where the Access .mdb file is. For instance, in c: \MontvillePics, there exists MontvillePics.mdb. Then under c: \MontvillePics\pics are the actual .jpg files. Right now, I have the paths hard coded with those...
10
3017
by: crazycooter | last post by:
I found an old thread on this (http://groups.google.com/group/alt.php/ browse_thread/thread/751edb9c723316c4/ea9bf92a9c6b807c?lnk=gst&q=mail() +duplicate&rnum=7#ea9bf92a9c6b807c), but there didnt seem to be a resolution. I also noticed that this was a pretty old thread and there didn't seem to be anything newer in the search results. Regardless, I have a very similar problem; I am consistently getting five emails per each PHP mail()...
1
1990
by: DR | last post by:
mySqlBytes.buffer is getting converted to BigEndian even though both SQL server 2005 and the CLR function are on the same machine which shows BitConverter.IsLittleEndian == true in tsql: select * from dbo.MY_CLR_FUNCTION(cast(1024 as binary(4))) public static int MY_CLR_FUNCTION(SqlBytes mySqlBytes) in debugger binaryData.buffer now shows bigendian!! 0 byte
13
2799
by: lawpoop | last post by:
Hello all - I have a two part question. First of all, I have a website under /home/user/www/. The index.php and all the other website pages are under /home/user/www/. For functions that are used in multiple files, I have php files under / home/user/www/functions/. These files simply have So, in index.php and other files, I have
4
2318
Lokean
by: Lokean | last post by:
The problem: Company was bought out and we are bringing everything into complience. Passwords are not secure and do not need to be.(required by software we are using) Old passwords *may or may not have been hard coded* in SQL SERVER database to validate (each account was setup with the same generic password). Need to check each proc or function for presense of hard-coded password. We have hundreds of functions that may or may not...
0
8402
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, 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...
0
8315
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8829
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8508
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,...
0
7341
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, 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...
0
5633
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();...
0
4164
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...
2
1962
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1627
bsmnconsultancy
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.