473,406 Members | 2,705 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,406 software developers and data experts.

Running a EXE with command line parameters in VB 2005

Hi Guys, im trying to get VB to run the regedit.exe function with the following command line

regedit.exe /E C:\VB.txt "HKEY_LOCAL_MACHINE\Software\Aberlink 3D"

Anybody have any ideas? The problem i have is getting VB 2005 to export an entire subkey rather than just one value at a time. Am i going down the right route with using regedit or is there a function within .net that will do this for me?

Thanks in advance

Ben
Aug 2 '07 #1
14 3412
Plater
7,872 Expert 4TB
Check the Process class.
It will take a filename and arguments

There is also a Registry class for editing the Registry settings though
Aug 2 '07 #2
Cheers Plater, but ive been using the process class and it doesn't like and parameters after the .exe ive also played with the registry class but there isnt a function to export a part of the registry :(
Aug 2 '07 #3
Plater
7,872 Expert 4TB
Cheers Plater, but ive been using the process class and it doesn't like and parameters after the .exe ive also played with the registry class but there isnt a function to export a part of the registry :(
What does your code look like for the arguments and the like?
Aug 2 '07 #4
Here is the line ive been playing with:

Expand|Select|Wrap|Line Numbers
  1.   Private Sub ExportReg_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExportReg.Click
  2.         Process.Start("regedit.exe /E C:\Regtest.reg "HKEY_LOCAL_MACHINE\Software\Aberlink 3D")
  3.     End Sub
But it refuses to let me run the .exe with added parameters, i delved into the My.computer.registry functions again with no luck.

Thanks again
Aug 3 '07 #5
TRScheel
638 Expert 512MB
Here is the line ive been playing with:

Expand|Select|Wrap|Line Numbers
  1.   Private Sub ExportReg_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExportReg.Click
  2.         Process.Start("regedit.exe /E C:\Regtest.reg "HKEY_LOCAL_MACHINE\Software\Aberlink 3D")
  3.     End Sub
But it refuses to let me run the .exe with added parameters, i delved into the My.computer.registry functions again with no luck.

Thanks again
Process.Start has an overload where you can pass parameters. Its something like:

Expand|Select|Wrap|Line Numbers
  1. Process.Start(string Filename, string Arguements);
Aug 3 '07 #6
Process.Start has an overload where you can pass parameters. Its something like:

Expand|Select|Wrap|Line Numbers
  1. Process.Start(string Filename, string Arguements);
Thanks that seems to have done the trick, below is the function of clicking a button, the command works fine until the Reg key i want to export has a space somewhere in the key name.
IE Aberlink 3D shown below:

Expand|Select|Wrap|Line Numbers
  1.     Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
  2.         Process.Start("C:\Windows\Regedit.exe", "/e C:\Joy.xxx HKEY_LOCAL_MACHINE\SOFTWARE\Aberlink 3D")
  3.  
  4.     End Sub
Anybody know how to get around this??? been trying for the last day. The command works fine if i were to use the "Ahead" key rather than "Aberlink 3D" for example
Aug 29 '07 #7
Plater
7,872 Expert 4TB
You are going to need to put the argument itself in quotes (as opposed to just a string in code)

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
  3.         Process.Start("C:\Windows\Regedit.exe", "/e \C:\Joy.xxx \"HKEY_LOCAL_MACHINE\SOFTWARE\Aberlink 3D\"")
  4.  
  5.     End Sub
  6.  
The \" is used to insert a " inside a string, so just make sure they wrap around the correct parts
Aug 29 '07 #8
still wont run with that space between "Aberlink 3D". im so close if it werent for this silly void between words!
Aug 29 '07 #9
Plater
7,872 Expert 4TB
Try "[" or "(" or something then?
Or look up the help for that command on msdn?
Aug 29 '07 #10
still no joy, VB obviously sees the space and assumes that the "3D" is a seperate parameter. I cant see any way of getting round it unless VB has its own export function. All the functions i have found only include low level functions like, read, write, create and delete. i will venture on though!
Aug 30 '07 #11
The argument you are using, is it a file? If it is a file you will need the full file extension...

also have you tried typing exactly what you have in the string into the command prompt...?

I managed to get this working, with the space, but it is using a txt file not a directory, hope this helps.

Expand|Select|Wrap|Line Numbers
  1.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  2.         Process.Start("notepad.exe", "C:\Documents and Settings\User\Desktop\test test.txt")
  3.     End Sub
  4.  
Also it appears you are using more than one argument, maybe you have to put them as seperate strings, although i doubt it, i'm just thinking outloud...

any additional info u have on the prob will help with the solution!

Martin
Aug 30 '07 #12
Hi Martin, the code i have works providing there isnt a space anywhere in the registry path i want to export. Which is a real pisser considering the part of the registry i need is some software called "Aberlink 3D". I just need to code it so it sees "Aberlink" and "3D" as the complete path name rather than two seperate entities.
Sep 3 '07 #13
Hi Martin, the code i have works providing there isnt a space anywhere in the registry path i want to export. Which is a real pisser considering the part of the registry i need is some software called "Aberlink 3D". I just need to code it so it sees "Aberlink" and "3D" as the complete path name rather than two seperate entities.
So it is a directory then.... try

Expand|Select|Wrap|Line Numbers
  1. Process.Start("C:\Windows\Regedit.exe", "/e C:\Joy.xxx \HKEY_LOCAL_MACHINE\SOFTWARE\Aberlink 3D\")
  2.  
To be honest i have never used the function that you are using, but I have used command line args, and when passing a directory I found that you had to pass the full name with the final "\".

Report back, this is annoying me, tho i can appreciate not as much as it annoys you!

Martin
Sep 3 '07 #14
Martin you are a saint my friend! i have managed to get it to export finally!

Expand|Select|Wrap|Line Numbers
  1.  Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  2.         Process.Start("c:\Windows\regedit.exe", "/e c:\AB3DSettings.reg ""HKEY_LOCAL_MACHINE\Software\Aberlink 3D\""")
  3.  
  4.     End Sub
  5.  
I had to double quote the arguement but the \ has done the trick. My hero :)
Thanks again to Plater for you help, most appreciated :)
Sep 4 '07 #15

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Christopher Brandsdal | last post by:
Hi! I have a problem running my code on 2000 server and iis5.0. The code runs perfectly on my localhost (xp iis5.1) but when i run it on 2000 server iis5.0 I get this error: ...
7
by: Ross Presser | last post by:
OK, I've been researching this problem and can't find a definitive answer yet. The situation is one that seems to have come up a few times to different folks. I am writing an application that...
2
by: bbxrider | last post by:
for win2k adv server/iis5.0 trying to run an external program from my asp routine that has multiple parameters, see following set shell = server.createobject("wscript.shell") shell.Run...
6
by: jsw_nz | last post by:
Helo, my first post here.... I am trying to run an agent application that converts and imports two tables from MS Access into mySql. (Intelligent Converters - Access2mySql) I have run similar...
1
by: Peter Rilling | last post by:
I have an EXE that I would like to be able to run from either the command-line or as a windows service. Is there a way that I can tell which context the program is running in? Basically, if it...
22
by: M K | last post by:
Heres my SP: ( i am trying to add more than 1 field but get the same error no matter how many i try to add, i thought i would try to insert the primary key only and work up from there but the...
9
by: Brad Pears | last post by:
I want to pass an integer customer# into my vb app from the command line when I run it... something like this.... c:\program files\Myapp\myvbapp.exe 100 So in the case above, when my...
1
by: Claire | last post by:
Hi, I'm trying to run mysqldump.exe from my c# application, running on windows vista with visual studio 2005. The following code does not produce the output file. The same line used in a command...
1
by: =?Utf-8?B?Q2lhcmFuIE8nJ0Rvbm5lbGw=?= | last post by:
On reflection, you could possibly make the app a self extracting zip file which extracts the EXE and a settings file and then starts the app, then when you app closes, it can repack the settings...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
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...

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.