Board index » Visual Studio » Shell function

Shell function

Visual Studio271
Hi All,

I've used this many times before but all of a sudden I can't get it to work.

This simple line:

Shell "cmd.exe C:\winnt\system32\ipconfig.exe"



will not work. It starts an instance of cmd.exe but ipconfig does not execute.

I've tried variations of course:

Shell "cmd.exe ipconfig"

Shell "cmd.exe ipconfig.exe"

Shell "cmd.exe ""C:\winnt\system32\ipconfig.exe"""

and many more!

retval = Shell ("cmd.exe C:\winnt\system32\ipconfig.exe")



I am I losing my mind or is there a syntax problem somewhere?





Dan Artuso, Access MVP


-
 

Re:Shell function



"Grinder" <grinder@no.spam.maam.com>wrote in message

Quote


"Dan Artuso" <dartuso@NoSpampagepearls.com>wrote in message

news:OAvx9X7fDHA.2328@TK2MSFTNGP09.phx.gbl...

>Hi All,

>I've used this many times before but all of a sudden I can't

get it to work.

>This simple line:

>Shell "cmd.exe C:\winnt\system32\ipconfig.exe"

>

>will not work. It starts an instance of cmd.exe but ipconfig

does not execute.

>I've tried variations of course:

>Shell "cmd.exe ipconfig"

>Shell "cmd.exe ipconfig.exe"

>Shell "cmd.exe ""C:\winnt\system32\ipconfig.exe"""

>and many more!

>retval = Shell ("cmd.exe C:\winnt\system32\ipconfig.exe")

>

>I am I losing my mind or is there a syntax problem somewhere?



How about:



Shell "cmd.exe /k ipconfig.exe"



Assuming, of course, that cmd.exe and ipconfig.exe both exist

in the system path.



If you're going to run this on 9x systems, you'll want to use

Environ$("COMSPEC") instead of cmd.exe.



If you use Environ$("COMSPEC"), it will be good for all Windows versions.



Rick - MVP





-