473,395 Members | 1,676 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,395 software developers and data experts.

ShellExecute and file output

I currently start a target executable written in VB.Net from an
application that uses a C-script language.

I start the target executable using ShellExecute in the C-script. The
target runs fine like this except for the fact that the target can't
write to a log file. If I run the target independently of the C-script
application, the log file is created and written to without a hitch.

There is no error produced - the log file just never appears. If I put
a log file in the directory, it is not appended.
The code is as follows:

Dim tx as TextWriter = File.AppendText("Log.txt")

tx.WriteLine( sLogText )

tx.Close
The ShellExecute command is:

result = ShellExecute(
HWND_DESKTOP, "open", "target.exe", "-1", NULL,
SW_SHOWNORMAL);
I get the impression I'm missing something simple here, but I don't know
what it is.

TIA

Frank Maxey

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 21 '05 #1
4 3405
"fdmaxey" <fd*****@devdex.com> schrieb:
I start the target executable using ShellExecute in the C-script. The
target runs fine like this except for the fact that the target can't
write to a log file. If I run the target independently of the C-script
application, the log file is created and written to without a hitch.

There is no error produced - the log file just never appears. If I put
a log file in the directory, it is not appended.
[...]
Dim tx as TextWriter = File.AppendText("Log.txt")
[...]
result = ShellExecute(
HWND_DESKTOP, "open", "target.exe", "-1", NULL,
SW_SHOWNORMAL);


Try passing the working directory (e.g., the application's directory)
instead of passing 'NULL' in the 'lpDirectory' parameter.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #2
Dim tx as TextWriter = File.AppendText("Log.txt")


Since you're using a relative file path the file will opened from the
current directory, which may differ depending on how you run the
application. Make sure Environment.CurrentDirectory is what you expect
it to be.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 21 '05 #3
That was the problem. Thanks.

Frank Maxey

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 21 '05 #4
That was the problem. Thanks.

Frank Maxey

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 21 '05 #5

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

Similar topics

9
by: Josh Mayfield | last post by:
Note: There is considerable background detail here, but I do have three questions, which are clearly marked and appear right before the sample code. I have a legitimate need to launch an EXE...
3
by: Wiktor Zychla | last post by:
I have a problem I cannot solve. My application hosts IE activex control. I follow the standard procedure: I just aximp shdocvw.dll. Note that this gives you two files: axshdocvw.dll and...
0
by: the_openFace | last post by:
I'm trying to display the shell's property page for various files and I'm using this code: class Win32Shell { // ... other stuff here public static extern Int32 ShellExecute( Int32 hwnd,...
0
by: the openBack | last post by:
I'm trying to display the shell's property page for various files and I'm using this code: class Win32Shell { // ... other stuff here public static extern Int32 ShellExecute( Int32 hwnd,...
5
by: The8thSense | last post by:
Hi, i would like to invoke another applcation in my program.I 've tried shellexecute ,but it doesnt work . here is my code : ShellExecute(0, "open", "C:\windows\system32\notepad.exe", vbNull,...
5
by: Jedi10180 | last post by:
Does ShellExecute work in VB2005? I am trying to open a pdf with a button - I get no errors, but nothing is happening. Here is my code: Option Explicit On Public Class frmPROTest Const...
5
by: =?Utf-8?B?VG9tYXM=?= | last post by:
Hello, Somebody knows which is the equivalent one in C++/CLI ? HINSTANCE ShellExecute(HWND hwnd, LPCTSTR lpOperation, LPCTSTR lpFile, LPCTSTR lpParameters, LPCTSTR lpDirectory, INT nShowCmd
2
by: John Smith | last post by:
Hi, I have an access database form with an image. I'm trying to create an onclick event on the image so that when a user clicks on the image it opens that file with the default viewer the...
0
by: khokhar.hassan | last post by:
i hava a VB application that is used to run different application by using ShellExecute. These applications also includes Adode reader to open .pdf files. The application is working fine with...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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,...
0
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
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...

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.