Why this code is not working???

  • Thread starter Thread starter JH
  • Start date Start date
J

JH

Can somebody help me here. The following code works fine till the last
statement. It changes to the directory
but fails to execute the command install.cmd. The file install.cmd is
located at the directory name.
Thanks

Dim directoryName As String

Dim WshShell


directoryName =
Path.GetDirectoryName([Assembly].GetExecutingAssembly().Location)


WshShell = CreateObject("Wscript.Shell")

WshShell.Run("cmd /k cd " & directoryName & "\" & "Install.cmd")
 
* "JH said:
Can somebody help me here. The following code works fine till the last
statement. It changes to the directory
but fails to execute the command install.cmd. The file install.cmd is
located at the directory name.

Why not use 'System.Diagnostics.Process.Start'?
 
Why not use 'System.Diagnostics.Process.Start'?

Do you know who did give this method to John yesterday?

It has a style that looks to me to....................

\\\
Shell("C:\bla.exe")
///

:-)

Cor
 
* "Cor said:
Do you know who did give this method to John yesterday?

It has a style that looks to me to....................

\\\
Shell("C:\bla.exe")
///

:-)

Sorry, I don't understand.

BTW: I have adapted the code Fergus and you developed for sending mails
by opening the default mail client. I played around and I found out
that subject and message will have to be encoded too (otherwise there
may be wrong results if the message or the subject contain certain
characters like "@" and/or "&". Here's the final version:

\\\
Imports System.Diagnostics
Imports System.Web

Public Sub StartDefaultMail( _
ByVal [To] As String, _
Optional ByVal Subject As String = "", _
Optional ByVal Message As String = "" _
)
Try
Dim psi As New ProcessStartInfo
psi.UseShellExecute = True
psi.FileName = _
"mailto:" & HttpUtility.UrlEncode([To]) & _
"?subject=" & HttpUtility.UrlEncode(Subject) & _
"&body=" & HttpUtility.UrlEncode(Message)
Process.Start(psi)
Catch ex As Exception
Throw New Exception("Default mail client could not be started.", ex)
End Try
End Sub
///
 
Hi Herfried,

Thanks, this one was more Fergus than me.

It was more that he said it could not, and I knew it could and then he made
this code.

I will investigate what you wrote but not today anymore.

That "Shell" is because yesterday someone asked what methods where there,
and I was just looking at that diagnostic procedures so I gave an answer.

And yes of course Herfried comes with an answer for the shell.

And now you ask when the shell is used.

:-))

Cor
 
Cor,

* "Cor said:
Thanks, this one was more Fergus than me.

It was more that he said it could not, and I knew it could and then he made
this code.

I will investigate what you wrote but not today anymore.

:-) Let me know if you find out something interesting.
That "Shell" is because yesterday someone asked what methods where there,
and I was just looking at that diagnostic procedures so I gave an answer.

And yes of course Herfried comes with an answer for the shell.

And now you ask when the shell is used.


:-))

:-))) -- Now I understand...
 
Back
Top