473,473 Members | 2,178 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Application.StartupPath and a command

I am trying to run a command from a command prompt using the shell command.
Here is the syntax I want to execute:

Shell(lblMameExePath.Text & " -listinfo >" & Application.StartupPath &
"\MameGames.cfg", AppWinStyle.NormalFocus, True)
The problem is that the parameter Application.StartupPath has spaces
(C:\Program Files, for instance) and won't execute from a command prompt
without being incased in quotes. I can't figure out the proper syntax with
my quotes.

Help,
John


Nov 20 '05 #1
8 3663
* "jcrouse" <me> scripsit:
I am trying to run a command from a command prompt using the shell command.
Here is the syntax I want to execute:

Shell(lblMameExePath.Text & " -listinfo >" & Application.StartupPath &
"\MameGames.cfg", AppWinStyle.NormalFocus, True)
The problem is that the parameter Application.StartupPath has spaces
(C:\Program Files, for instance) and won't execute from a command prompt
without being incased in quotes. I can't figure out the proper syntax with
my quotes.


\\\
Shell(lblMameExePath.Text & " -listinfo >""" & Application.StartupPath & "\MameGames.cfg""", AppWinStyle.NormalFocus, True)
///

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #2
Well at least in the watch window the correct syntax seems to be this code:

Shell(lblMameExePath.Text & " -listinfo >" & """" & Application.StartupPath
& "\Games.cfg" & """", AppWinStyle.NormalFocus, True)

Here is what it displays in the watch window:

Watch string:

lblMameExePath.Text & " -listinfo >" & """" & Application.StartupPath &
"\MameGames.cfg" & """"

String Value:

"C:\Mame\Mame.exe -listinfo >"C:\VB Projects\XLM
App\Writer\bin\MameGames.cfg""

If you remove the beginning and end quotes because it is a string it is the
exact syntax I need. From a command prompt it works great. However, from
within the code it does nothing.

Ken I also tried your code and it too looked correct in the watch window but
failed to create the file. Both of our syntax's go through the motions. It
takes about 60 seconds to create. It is a 20MB text file. However, after
execution, no file appears. I have searched my entire harddrive and NOTHING.
I'm stumped. The tought thing is that it will still scroll all the text to
the screen if the path is bad so I can't really tell whether its writing a
file or just outputting to the screen. Any more ideas?

The next thing after I get this working will be to create the file the first
time during the install routine. I'm not quite sure how to do this either,
but haven't looked into it yet.

Thank you,
John

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:2j*************@uni-berlin.de...
* "jcrouse" <me> scripsit:
I am trying to run a command from a command prompt using the shell command. Here is the syntax I want to execute:

Shell(lblMameExePath.Text & " -listinfo >" & Application.StartupPath &
"\MameGames.cfg", AppWinStyle.NormalFocus, True)
The problem is that the parameter Application.StartupPath has spaces
(C:\Program Files, for instance) and won't execute from a command prompt
without being incased in quotes. I can't figure out the proper syntax with my quotes.
\\\
Shell(lblMameExePath.Text & " -listinfo >""" & Application.StartupPath &

"\MameGames.cfg""", AppWinStyle.NormalFocus, True) ///

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 20 '05 #3
* "jcrouse" <me> scripsit:
Well at least in the watch window the correct syntax seems to be this code:


<URL:http://dotnet.mvps.org/dotnet/samples/miscsamples/downloads/RedirectConsole.zip>

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #4
Herfried........Thank you but that code is way over my head. Can it really
take THAT MUCH just to send a string to a command prompt? There has to be an
easier way.

Thanks again,
John
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:2j*************@uni-berlin.de...
* "jcrouse" <me> scripsit:
Well at least in the watch window the correct syntax seems to be this
code:
<URL:http://dotnet.mvps.org/dotnet/sample...ds/RedirectCon
sole.zip>
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 20 '05 #5
* "jcrouse" <me> scripsit:
Herfried........Thank you but that code is way over my head. Can it really
take THAT MUCH just to send a string to a command prompt? There has to be an
easier way.


It's not as easy. You will have to launch "cmd.exe" and then call the
other executable with "> ..." specified. The "> ..." part is a feature
of the command shell.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #6
Well, I've been trying for three or four hours with no luck. It seems to not
like the redirect ">" part. Anyone have any other ideas?

Thanks,
John

"jcrouse" <me> wrote in message news:Oj*************@TK2MSFTNGP10.phx.gbl...
I am trying to run a command from a command prompt using the shell command. Here is the syntax I want to execute:

Shell(lblMameExePath.Text & " -listinfo >" & Application.StartupPath &
"\MameGames.cfg", AppWinStyle.NormalFocus, True)
The problem is that the parameter Application.StartupPath has spaces
(C:\Program Files, for instance) and won't execute from a command prompt
without being incased in quotes. I can't figure out the proper syntax with
my quotes.

Help,
John

Nov 20 '05 #7
Well I got it working, kind of.....Here is the latest. This code works.

If lblMameExePath.Text <> "" Then

Dim sr As StreamWriter = File.CreateText("C:\games.bat")

sr.WriteLine(lblMameExePath.Text & " -listinfo >""" &
Application.StartupPath & "\mamegames.cfg""")

sr.Close()

Dim response As String

response = MsgBox("You will be notified when the operation is
complete", MsgBoxStyle.OKOnly, "CPViewer")

Shell("C:\games.bat", AppWinStyle.NormalFocus, True)

response = MsgBox("Your file has been created successfully.",
MsgBoxStyle.OKOnly, "CPViewer")

Else

Dim response As String

response = MsgBox("You must first specify the path to your mame
executable", MsgBoxStyle.OKOnly, "CPViewer")

End If
As long as I specify the path in the shell command. If I use
Application.StartupPath & "\games.bat" in the sr.WriteLine line it
write the file great. However, if I use the same exact syntax in the shell
command is says that the file does not exist. Even the watch window has the
exact same string for both parameters. Can anyone explain this behavior? I
really hate to hard code paths in an application.

Thank you,
John
"jcrouse" <me> wrote in message
news:e1**************@tk2msftngp13.phx.gbl...
Well, I've been trying for three or four hours with no luck. It seems to not like the redirect ">" part. Anyone have any other ideas?

Thanks,
John

"jcrouse" <me> wrote in message

news:Oj*************@TK2MSFTNGP10.phx.gbl...
I am trying to run a command from a command prompt using the shell

command.
Here is the syntax I want to execute:

Shell(lblMameExePath.Text & " -listinfo >" & Application.StartupPath &
"\MameGames.cfg", AppWinStyle.NormalFocus, True)
The problem is that the parameter Application.StartupPath has spaces
(C:\Program Files, for instance) and won't execute from a command prompt
without being incased in quotes. I can't figure out the proper syntax with my quotes.

Help,
John


Nov 20 '05 #8
Resolved! I specified the criteria in a variable and then used the variable
in both places and it works. I'm confused. Oh well.

John

"jcrouse" <me> wrote in message news:Oj*************@TK2MSFTNGP10.phx.gbl...
I am trying to run a command from a command prompt using the shell command. Here is the syntax I want to execute:

Shell(lblMameExePath.Text & " -listinfo >" & Application.StartupPath &
"\MameGames.cfg", AppWinStyle.NormalFocus, True)
The problem is that the parameter Application.StartupPath has spaces
(C:\Program Files, for instance) and won't execute from a command prompt
without being incased in quotes. I can't figure out the proper syntax with
my quotes.

Help,
John

Nov 20 '05 #9

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

Similar topics

5
by: Robert Magnusson | last post by:
Hi All, This is sure to be an easy question. I am wondering what the accepted standard is for referencing a sub-folder below the application.exe folder? In VB6 you simply used App.Path and...
5
by: Eranga | last post by:
In c# windows applicatiopns the Application.StartupPath can be used to find the path for the executable file. How can the same be found for a console application?(we can't use application because...
2
by: Ron | last post by:
Hello, I would like to retrieve the startupPath from a console application. It appears that a console application does not recognize Application, so I can't access StartupPath. Is there a way...
1
by: Sean | last post by:
Hi I created a VB.NET console app. I try to use the Application.StartupPath() but got an error: Name 'Application' is not declared. Any idea? Thanks. Sean
3
by: hayworth | last post by:
I had some code to build the name of a file: ' Build the name of the XML config file. g_strFiles.strConfig = My.Computer.FileSystem.CombinePath(Application.StartupPath, "\Settings\Config...
2
by: al jones | last post by:
There is no installation for the program I wrote, one just copies the files to some directory and runs it from there, I have both a working program and help file (.chm). From within the IDE...
0
by: =?Utf-8?B?Sm9iIExvdA==?= | last post by:
I am using BulkLoad from .NET application as follows SQLXMLBULKLOADLib.SQLXMLBulkLoad4Class obj = new SQLXMLBULKLOADLib.SQLXMLBulkLoad4Class(); obj.ConnectionString =...
5
getgagan
by: getgagan | last post by:
how to find Main folder where bin folder exists using application.startuppath in c# IF application.startuppath=D:\Test\ThreadExample\DnsLookup\DnsLookup\bin\Debug Then i need to find the...
3
by: Joca | last post by:
I'm making a program that at some point needed to know what the path to it's own directory was, so i quickly made a side project just to test how this works ending up with the use of...
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,...
1
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
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
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,...
0
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...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.