9 Replies - 64193 Views - Last Post: 03 December 2007 - 06:22 AM Rate Topic: -----

#1 DavidMLevine  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 09-February 05

Shell Command

Posted 09 February 2005 - 06:27 PM

I need a code which will open a file (or list) using another.

ie.. shell ("c:\textfile.txt using c:\notepad.exe")

I cant believe the junk I get stuck on sometimes! :sleepy:
Is This A Good Question/Topic? 0
  • +

Replies To: Shell Command

#2 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,507
  • Joined: 12-July 02

Re: Shell Command

Posted 09 February 2005 - 08:00 PM

Give this a try...
Shell "notepad.exe c:\somefile.txt"


Was This Post Helpful? 0
  • +
  • -

#3 DavidMLevine  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 09-February 05

Re: Shell Command

Posted 09 February 2005 - 08:17 PM

Well I tried:

Shell("C:\Adobe Project\001.EXE C:\Adobe Project\Sunset.JPG")

It is a Photoshop droplet (001) and an image. It says "Could not run the droplet because the file could not be found."

This tells me that I am close, but it doesn't seem to like the 2nd reference. :crazy:
Was This Post Helpful? 0
  • +
  • -

#4 tel0r  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 1
  • View blog
  • Posts: 27
  • Joined: 22-February 05

Re: Shell Command

Posted 22 February 2005 - 03:20 PM

Private Declare Function ShellExecute Lib "shell32.dll" Alias _
"ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As _
String, ByVal lpFile As String, ByVal lpParameters As String, _
ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

'Useage:
Dim FilePath As String
FilePath = "C:\Adobe Project\Sunset.JPG"
Call ShellExecute(0, "Open", FilePath, "", "", 1)
Was This Post Helpful? 0
  • +
  • -

#5 DavidMLevine  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 09-February 05

Re: Shell Command

Posted 22 February 2005 - 05:34 PM

Well what I ended up with is this:

Shell("C:\Adobe Project\050.EXE ""C:\Adobe Project\blank.jpg""")

The quotes made the difference.

Thanks all!
Was This Post Helpful? 0
  • +
  • -

#6 samsydney  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 11-May 07

Re: Shell Command

Posted 11 May 2007 - 01:37 AM

Hi

I am new to VB6 programming.

I am stuck with Shell command. I want to run a EXE with command line arguments i.e.

Shell ("c:\myapplication.exe argument1 argument2")

but it does not work.

When i run it without any arguments it works.

Please help ASAP.

regards

SAM
Was This Post Helpful? 0
  • +
  • -

#7 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,507
  • Joined: 12-July 02

Re: Shell Command

Posted 12 May 2007 - 12:24 PM

Try
Shell ("c:\myapplication.exe" "argument1" "argument2")


Was This Post Helpful? 0
  • +
  • -

#8 SMadsen01  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 02-December 07

Re: Shell Command

Posted 02 December 2007 - 05:40 PM

Is there a way I can include spaces in a filename in a shell command?
I tried
		Shell("C:\Program Files\Microsoft MapPoint\MapPoint.exe C:\Test Map.ptm", vbNormalFocus)



and I got the message "The file does not exist in the specified location"

but when I delete the space in both the filename and the code, it works fine. I made sure everything matched in the path and my code, and I have tried with several files. They always work if they don't have any spaces, and fail if they do

PS. I am using VB 2005 Express Edition
Was This Post Helpful? 0
  • +
  • -

#9 kwikone  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 1
  • View blog
  • Posts: 10
  • Joined: 25-October 07

Re: Shell Command

Posted 03 December 2007 - 05:36 AM

View PostSMadsen01, on 2 Dec, 2007 - 07:40 PM, said:

Is there a way I can include spaces in a filename in a shell command?
I tried
		Shell("C:\Program Files\Microsoft MapPoint\MapPoint.exe C:\Test Map.ptm", vbNormalFocus)



and I got the message "The file does not exist in the specified location"

but when I delete the space in both the filename and the code, it works fine. I made sure everything matched in the path and my code, and I have tried with several files. They always work if they don't have any spaces, and fail if they do

PS. I am using VB 2005 Express Edition

You need to enclose the name (and parameters if they have spaces) within quotes, in just the same manner as is needed from the command line. for example:
Shell("C:\Program Files\Microsoft MapPoint\MapPoint.exe ""C:\Test Map.ptm""", vbNormalFocus)
Was This Post Helpful? 0
  • +
  • -

#10 no2pencil  Icon User is offline

  • Admiral Fancy Pants
  • member icon

Reputation: 5388
  • View blog
  • Posts: 27,384
  • Joined: 10-May 07

Re: Shell Command

Posted 03 December 2007 - 06:22 AM

View PostSMadsen01, on 2 Dec, 2007 - 05:40 PM, said:

Is there a way I can include spaces in a filename in a shell command?
I tried
		Shell("C:\Program Files\Microsoft MapPoint\MapPoint.exe C:\Test Map.ptm", vbNormalFocus)



and I got the message "The file does not exist in the specified location"

but when I delete the space in both the filename and the code, it works fine. I made sure everything matched in the path and my code, and I have tried with several files. They always work if they don't have any spaces, and fail if they do

PS. I am using VB 2005 Express Edition



Shell("\"C:\Program Files\Microsoft MapPoint\MapPoint.exe\" C:\Test Map.ptm", vbNormalFocus)



Was This Post Helpful? 0
  • +
  • -

Page 1 of 1