Shell (" CMD ") 'can be normal open a DOS window
Shell (" dir "); Error
Error:
"System. IO. FileNotFoundException" type of untreated abnormalities in Microsoft.
in VisualBasic. DLL
Behind the instructions are simple, there are a lot of other DOS command, or a batch file
For help, thank you
CodePudding user response:
Shell (" dir ") mean, run "dir", certainly can't find a executable named dir,There are two kinds of treatment method of
One is: the process, using startinfo run CMD. Exe, and then to take over the standard input, output, and error input and output
Another is: use the shell CMD. Exe/c specific command to run,
CodePudding user response:
Dir function that can be executed directly obtained without Shell functions,Dir function that returns a String, to a filename, directory name, or folder name, it must file with the specified or property, or a disk volume label match,
Dir function example
This example USES the Dir function to check some file or directory exists, on Macintosh computers, the default name is "HD" drive, and the path parts separated by a colon instead of backslash, and Microsoft Windows wildcard in Mac can be used as a valid characters appeared in the file name, also can use MacID function to the specified file group,
Dim MyFile MyPath, MyName
'return to "WIN. INI" (if the file exists),
MyFile=Dir (" C: \ WINDOWS \ WINDOWS ini ")
'return with specified filename extension, if more than one *. Ini file exists,
'function returns according to the condition of the first to find the file name,
MyFile=Dir (" C: \ WINDOWS \ *. Ini ")
'if a second call Dir function, but without any parameters, the function returns the same directory of the next *.ini file,
MyFile=Dir
'return to find the first implicit *. TXT file,
MyFile=Dir (" *.txt, "vbHidden)
'show C: \ directory name,
MyPath="c: " 'specified path,
MyName=Dir (MyPath, vbDirectory) 'looking for first,
The Do While MyName & lt;> "" 'began circulating,
'to skip the current directory and the upper directory,
If MyName & lt;> ". "And MyName & lt;> ".. "Then
'using a comparison to determine the MyName represents one directory,
If (GetAttr (MyPath & amp; MyName) And vbDirectory)=vbDirectory Then
The Debug. Print MyName 'if it is a directory, to display the name,
End the If
End the If
MyName=Dir 'find next directory,
Loop
CodePudding user response:
Shell (" CMD/c dir ")