A Windows XP help forum. PCbanter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » PCbanter forum » Microsoft Windows XP » General XP issues or comments
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Cannot get Shell to work



 
 
Thread Tools Display Modes
  #1  
Old April 13th 18, 03:28 AM posted to microsoft.public.windowsxp.general
Robert Baer[_2_]
external usenet poster
 
Posts: 126
Default Cannot get Shell to work

Full program as-is below. Excel 2010.
Shell refuses to work (PC not MAC), always get error "File not found"
no matter how i mangle that line.

Naturally, there is NO "help" as this is M$ we are talking about.

Sub TestDIR()

' Macro recorded 04/12/2018 by ROBERT BAER
'
destPath = "G:\ANALOG"
DaTm = Date$ + " " + Time$
Open pPath + "Log.TXT" For Append As #1
' error "File not found" any variant of Shell.
pState = Shell("DIR *.* LOOK.DIR", vbNormalFocus)
'QB3 FORMAT is SHELL "DIR *.BMP LOOK.DIR"
Stop
Print #1, DaTm + " to " + vNam
Close


End Sub

Help?
Thanks.
Ads
  #2  
Old April 13th 18, 05:31 AM posted to microsoft.public.windowsxp.general
Paul[_32_]
external usenet poster
 
Posts: 11,873
Default Cannot get Shell to work

Robert Baer wrote:
Full program as-is below. Excel 2010.
Shell refuses to work (PC not MAC), always get error "File not found"
no matter how i mangle that line.

Naturally, there is NO "help" as this is M$ we are talking about.

Sub TestDIR()

' Macro recorded 04/12/2018 by ROBERT BAER
'
destPath = "G:\ANALOG"
DaTm = Date$ + " " + Time$
Open pPath + "Log.TXT" For Append As #1
' error "File not found" any variant of Shell.
pState = Shell("DIR *.* LOOK.DIR", vbNormalFocus)
'QB3 FORMAT is SHELL "DIR *.BMP LOOK.DIR"
Stop
Print #1, DaTm + " to " + vNam
Close


End Sub

Help?
Thanks.


You know, you can debug runtimes with ProcMon
and watch what they attempt to do.

A favorite bug, is making a path with a space character
in the name, then watch as the shell tries to open

C:\users\Robert

instead of C:\users\Robert Baer\Downloads. And all
because the author of the script did not insulate
with double quotes. This technique causes the string
to be passed as an atomic item.

"C:\users\Robert Baer\Downloads"

I'm not going to debug your script, but I am going
to suggest starting this logger running, before the
script is executed. Set the filter (later) to select
just the script events. And see what it tried to
open() or stat() etc. To stop collecting ETW events,
go to the File menu and untick the tick box there.

Don't forget to check the supported OSes at the
bottom of the page here. The current version is for Vista+.

https://docs.microsoft.com/en-us/sys...nloads/procmon

In some languages, to put double quotes around double
quotes, requires escaping. In this example, the backslash
character is intended to indicate the next character
should be considered as a literal, rather than acted upon
as a closing quote in the script.

"\"C:\users\Robert Baer\Downloads\""

*******

From my Sent folder, the following links might work for WinXP.

Version 3.1

https://web.archive.org/web/20150117...rnals/bb896645

I had some trouble with the download link. I hope this works.

https://web.archive.org/web/20150208...essMonitor.zip

Paul
  #3  
Old April 13th 18, 03:56 PM posted to microsoft.public.windowsxp.general
JJ[_11_]
external usenet poster
 
Posts: 744
Default Cannot get Shell to work

On Thu, 12 Apr 2018 19:28:21 -0700, Robert Baer wrote:
Full program as-is below. Excel 2010.
Shell refuses to work (PC not MAC), always get error "File not found"
no matter how i mangle that line.

Naturally, there is NO "help" as this is M$ we are talking about.

Sub TestDIR()

' Macro recorded 04/12/2018 by ROBERT BAER
'
destPath = "G:\ANALOG"
DaTm = Date$ + " " + Time$
Open pPath + "Log.TXT" For Append As #1
' error "File not found" any variant of Shell.
pState = Shell("DIR *.* LOOK.DIR", vbNormalFocus)
'QB3 FORMAT is SHELL "DIR *.BMP LOOK.DIR"
Stop
Print #1, DaTm + " to " + vNam
Close

End Sub

Help?
Thanks.


The description of the Shell() function says:
"Runs an executable program and returns ..."

Meaning that, the function's first argument should be an executable program.
i.e. an executable file. DIR is an internal command of the Command Prompt
program, which is CMD.EXE.

So, in order to issue CMD internal command(s), use the /C switch of CMD.EXE.
e.g.:

CMD.EXE /C DIR *.* LOOK.DIR
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off






All times are GMT +1. The time now is 02:56 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 PCbanter.
The comments are property of their posters.