473,618 Members | 3,170 Online
Bytes | Software Development & Data Engineering Community
+ 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(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click

Dim strInput As String = Application.Sta rtupPath &
"\CreateMameGam esCFG.bat"

If lblMameExePath. Text <> "" Then

Dim sr As StreamWriter = File.CreateText (strInput)

sr.WriteLine(lb lMameExePath.Te xt & " -listinfo >""" &
Application.Sta rtupPath & "\mamegames.cfg """)

sr.Close()

Dim response As String

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

If File.Exists(str Input) Then

Shell(strInput, AppWinStyle.Hid e, True)

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

Else

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

End If

Else

Dim response As String

response = MsgBox("You must first specify the path to your mame
executable", MsgBoxStyle.OKO nly, "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.File NotFoundExcepti on' occurred in
microsoft.visua lbasic.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 4541
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(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click

Dim strInput As String = Application.Sta rtupPath &
"\CreateMameGam esCFG.bat"

If lblMameExePath. Text <> "" Then

Dim sr As StreamWriter = File.CreateText (strInput)

sr.WriteLine(lb lMameExePath.Te xt & " -listinfo >""" &
Application.Sta rtupPath & "\mamegames.cfg """)

sr.Close()

Dim response As String

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

If File.Exists(str Input) Then

Shell(strInput, AppWinStyle.Hid e, True)

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

Else

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

End If

Else

Dim response As String

response = MsgBox("You must first specify the path to your mame
executable", MsgBoxStyle.OKO nly, "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.File NotFoundExcepti on' occurred in
microsoft.visua lbasic.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.Diagnost ics.ProcessStar tInfo()
p.Verb = "print"
p.WindowStyle = ProcessWindowSt yle.Hidden
p.FileName = "C:\filename.do c"
p.UseShellExecu te = True
System.Diagnost ics.Process.Sta rt(p)
///
\\\
Dim p As New Process
p.StartInfo.Use ShellExecute = False
p.StartInfo.Red irectStandardOu tput = False
p.StartInfo.Arg uments = "\?"
p.StartInfo.Wor kingDirectory = "C:\mydir"
p.StartInfo.Fil eName = "myProg.exe "
p.Start()
///
\\\
Dim p As New Process
p.StartInfo.Use ShellExecute = False
p.StartInfo.Red irectStandardOu tput = True
p.StartInfo.Arg uments = myargumentstrin g
p.StartInfo.Wor kingDirectory = myworkdirectory string
p.StartInfo.Fil eName =C:\myprogram
p.Start()
Dim sr As IO.StreamReader = p.StandardOutpu t
Dim sb As New System.Text.Str ingBuilder("")
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(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click

Dim strInput As String = Application.Sta rtupPath &
"\CreateMameGam esCFG.bat"

If lblMameExePath. Text <> "" Then

Dim sr As StreamWriter = File.CreateText (strInput)

sr.WriteLine(lb lMameExePath.Te xt & " -listinfo >""" &
Application.Sta rtupPath & "\mamegames.cfg """)

sr.Close()

Dim response As String

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

If File.Exists(str Input) Then

Shell(strInput, AppWinStyle.Hid e, True)

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

Else

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

End If

Else

Dim response As String

response = MsgBox("You must first specify the path to your mame executable", MsgBoxStyle.OKO nly, "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.File NotFoundExcepti on' occurred in microsoft.visua lbasic.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 newsgroups I learned that there is a function in stdlib.h called system. int system(const char *command); First question, is the system command ANSI compliant. Because I include <cstdlib> and write std::system(command.c_str()); it looks like an...
8
35035
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 remember it is like: foo("cp file1 file2"); it is that simple, but cant remember. Could anyone here give me a clue?
2
6668
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 sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim command As String command = "systeminfo > C:\temp\sysinfo.txt"
2
6941
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 shell command. I found the shell command couldn't be run at background mode. It seemed that the shell_exec() function waits a return from the command. Because the command doesn't return, the shell_exec() waits until timeout reached. Using the '&'...
8
6982
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 Office\Office\Winword.exe O:\Patients Charts\mstest.doc" As soon as I try to open the same file on the O: drive (a directly connected server) , I get the following error message:"The document
25
62490
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 Files\Internet Explorer\Iexplore.exe http://www.google.ca", vbMaximizedFocus) End Sub i have a program thats been on my desktop for about a month now that uses these 3 lines of code(supposed to be 3 lines but it doesnt quite fit) and its been...
3
5354
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 string") where "command line argument as string" is the DOS command for the particular command line zip tool.
5
5077
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 passes these as arguments to a configurable shell script or OS command. I would like for the output generated from the shell script/command shall be displayed in a new javascript window once the form is submitted. Optimally a user should not...
3
6727
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 to execute a command call from within Access to execute a batch file (sample.bat). To do this, we use the Shell function, something like: Shell "cmd /c sample.bat"
7
6225
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 this shell script using the Subprocess module. Here is my code: def resultFromRunning_(command):
0
8453
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7124
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...
1
6098
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5552
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
4064
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...
0
4147
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2582
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 we have to send another system
1
1760
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1455
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.