473,493 Members | 4,347 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Shell Command Problem

I apologize for starting another thread but the old one had a weird subject
line. Anyways...here is the code:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim strInput As String = Application.StartupPath &
"\CreateMameGamesCFG.bat"

If lblMameExePath.Text <> "" Then

Dim sr As StreamWriter = File.CreateText(strInput)

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")

If File.Exists(strInput) Then

Shell(strInput, AppWinStyle.Hide, True)

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

Else

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

End If

Else

Dim response As String

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

End If

End Sub
The variable strInput contains a path and file name. It gets created fine
using the streamwriter. the If File.Exists even evaluates to true and the
code enters the if statement. When it gets to the shell command it errors
out whith the following error:

An unhandled exception of type 'System.IO.FileNotFoundException' occurred in
microsoft.visualbasic.dll

Additional information: File not found.

How can this possible be. It's almost like its a bug with the Shell command.
It was working for a while. Well, upon further checking here is what I got.
It worked in the GDI. I created an install package. Installed the app and it
worked. I messed around a little (not sure what I did) in the GDI and now it
won't work while in the GDI. I created another install package, installed it
and it works great but still won't work inside the GDI. Any ideas here? I'm
lost.

Thank you,

John



Nov 20 '05 #1
2 4527
Hi John,
Not a problem with the shell command being able to handle long file names?
Just a guess.
Bob
jcrouse wrote:
I apologize for starting another thread but the old one had a weird subject
line. Anyways...here is the code:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim strInput As String = Application.StartupPath &
"\CreateMameGamesCFG.bat"

If lblMameExePath.Text <> "" Then

Dim sr As StreamWriter = File.CreateText(strInput)

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")

If File.Exists(strInput) Then

Shell(strInput, AppWinStyle.Hide, True)

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

Else

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

End If

Else

Dim response As String

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

End If

End Sub
The variable strInput contains a path and file name. It gets created fine
using the streamwriter. the If File.Exists even evaluates to true and the
code enters the if statement. When it gets to the shell command it errors
out whith the following error:

An unhandled exception of type 'System.IO.FileNotFoundException' occurred in
microsoft.visualbasic.dll

Additional information: File not found.

How can this possible be. It's almost like its a bug with the Shell command.
It was working for a while. Well, upon further checking here is what I got.
It worked in the GDI. I created an install package. Installed the app and it
worked. I messed around a little (not sure what I did) in the GDI and now it
won't work while in the GDI. I created another install package, installed it
and it works great but still won't work inside the GDI. Any ideas here? I'm
lost.

Thank you,

John



--
Please take out the garbage before using reply address.

Nov 20 '05 #2
Hi John,

Did you already see what the process start can do for you?

Here some samples.

\\\
Dim p As New System.Diagnostics.ProcessStartInfo()
p.Verb = "print"
p.WindowStyle = ProcessWindowStyle.Hidden
p.FileName = "C:\filename.doc"
p.UseShellExecute = True
System.Diagnostics.Process.Start(p)
///
\\\
Dim p As New Process
p.StartInfo.UseShellExecute = False
p.StartInfo.RedirectStandardOutput = False
p.StartInfo.Arguments = "\?"
p.StartInfo.WorkingDirectory = "C:\mydir"
p.StartInfo.FileName = "myProg.exe"
p.Start()
///
\\\
Dim p As New Process
p.StartInfo.UseShellExecute = False
p.StartInfo.RedirectStandardOutput = True
p.StartInfo.Arguments = myargumentstring
p.StartInfo.WorkingDirectory = myworkdirectorystring
p.StartInfo.FileName =C:\myprogram
p.Start()
Dim sr As IO.StreamReader = p.StandardOutput
Dim sb As New System.Text.StringBuilder("")
Dim input As Integer = sr.Read
Do Until input = -1
sb.Append(ChrW(input))
input = sr.Read
Loop
///
I hope this helps a little bit?

Cor



I apologize for starting another thread but the old one had a weird subject line. Anyways...here is the code:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim strInput As String = Application.StartupPath &
"\CreateMameGamesCFG.bat"

If lblMameExePath.Text <> "" Then

Dim sr As StreamWriter = File.CreateText(strInput)

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")

If File.Exists(strInput) Then

Shell(strInput, AppWinStyle.Hide, True)

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

Else

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

End If

Else

Dim response As String

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

End If

End Sub
The variable strInput contains a path and file name. It gets created fine
using the streamwriter. the If File.Exists even evaluates to true and the
code enters the if statement. When it gets to the shell command it errors
out whith the following error:

An unhandled exception of type 'System.IO.FileNotFoundException' occurred in microsoft.visualbasic.dll

Additional information: File not found.

How can this possible be. It's almost like its a bug with the Shell command. It was working for a while. Well, upon further checking here is what I got. It worked in the GDI. I created an install package. Installed the app and it worked. I messed around a little (not sure what I did) in the GDI and now it won't work while in the GDI. I created another install package, installed it and it works great but still won't work inside the GDI. Any ideas here? I'm lost.

Thank you,

John



Nov 20 '05 #3

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

Similar topics

8
1333
by: Siemel Naran | last post by:
Hi. I'm writing a command shell that reads commands from standard input. At this point I have the command in a std::string. Now I want to execute this command in the shell. From the Borland...
8
35024
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...
2
6654
by: micahstrasser | last post by:
I have been trying for days to send a command to the command prompt through the shell() function in vb.net. For some reason it is not working. Here is the code: Private Sub Button1_Click(ByVal...
2
6931
by: ¹é¿ø¼® | last post by:
Hello, everybody. I want to call any shell command from php script using shell_exec(). The problem is that the next line of the php script would not be run until a few minutes after running the...
8
6968
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...
25
62420
by: dennijr | last post by:
ok, shell always used to be easy for me, now its starting to get annoying cause i dont know wats wrong heres the simplist code possible: Private Sub IExplorer_Click() a = Shell("C:\Program...
3
5344
by: ppuniversal | last post by:
Hi everyone, I am making using Shell() function to run a command line tool from my VB Application. I am using it to archive a folder. So I am using the code : Shell("command line argument as...
5
5065
by: inetquestion | last post by:
I am looking for a web interface for shell commands or shell scripts. Does anyone know of any exexisting php scripts which would solve this requirement? PHP form accepts input from a user, then...
3
6715
by: Max Vit | last post by:
I have come across a strange issue whilst trying to use a shell command call from Access and have spent some time trying to figure this out but can't find the cause as yet. The issue is: I need...
7
6199
by: Samuel A. Falvo II | last post by:
I have a shell script script.sh that launches a Java process in the background using the &-operator, like so: #!/bin/bash java ... arguments here ... & In my Python code, I want to invoke...
0
7118
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
6980
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
7192
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
5452
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
4579
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...
0
3087
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
1397
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 ...
1
637
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
282
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...

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.