how can one explain this problem of from the command line, getting wordpad to open a text file?
Note that it works in one case but not another case, as I indicate.
Windows 7, administrative command prompt.
C:\>dir c:\carp\a.txt
Volume in drive C has no label.
Volume Serial Number is 4645-5DCE
Directory of c:\carp
25/12/2020 17:17 5 a.txt
1 File(s) 5 bytes
0 Dir(s) 50,234,781,696 bytes free
C:\>
C:\>set PATH=C:\Program Files\Windows NT\Accessories
C:\>wordpad c:\carp\a.a
C:\>echo that worked
that worked
C:\>copy "c:\Program Files\Windows NT\Accessories\wordpad.exe" c:\carp
Overwrite c:\carp\wordpad.exe? (Yes/No/All): y
1 file(s) copied.
C:\>cd carp
C:\carp>SET PATH=
C:\carp>wordpad a.txt
C:\carp>echo "unable to create new document"
"unable to create new document"
C:\carp>
https://i.imgur.com/irpoAkN.png <-- pick of the "unable to create new document" window. Note that c:\carp\a.txt is not a new document, it's there as the DIR command shows.
how can one explain this problem of from the command line, getting wordpad to open a text file?
Moderator: DosItHelp
Re: how can one explain this problem of from the command line, getting wordpad to open a text file?
Two things:
- You destroy your Path environment. You may prepend or append a new value if necessary, like that:
- Why do you expect WordPad.exe is running if you copy it to the current directory? It won't! And since searching is performed in the current directory before searching in the PATH directories, you'll always get this message. Copy wordpad to your desktop and run it via double click. You'll facing the same error.
Steffen
- You destroy your Path environment. You may prepend or append a new value if necessary, like that:
Code: Select all
set "PATH=C:\Program Files\Windows NT\Accessories;%PATH%"
Steffen
Re: how can one explain this problem of from the command line, getting wordpad to open a text file?
Look at what I showed you there. It did. And i'd expect it toagerman/steffan wrote: Why do you expect WordPad.exe is running if you copy it to the current directory? It won't! And since searching is performed in the current directory before searching in the PATH directories, you'll always get this message...
When that window comes up
then looking in task manager or opening a new cmd prompt and doing
C:\Users\User>tasklist >z.z && find /i "wordpad" z.z
---------- Z.Z
wordpad.exe 33116 Console 1 12,324 K
C:\Users\User>
shows wordpad is running there. (which is a bit obvious anyway 'cos it's not like that's a standard window that comes up with other programs! that is a window that wordpad shows)
As for why it runs wordpad.
Because if you do SET PATH= (i.e. blank path), then it is the same as SET PATH=.
Another command one could do is
C:\carp>.\wordpad.exe a.txt <-- note that I copied wordpad to that directory as you saw in my first post.
That will run wordpad.
But it shows that "unable to create new document" message.
Re: how can one explain this problem of from the command line, getting wordpad to open a text file?
Yes, the wordpad process is running. Otherwise it wouldn't be able to generate the message box However, it can't run properly because it depends on libraries (dll), and maybe other files in the original location which you didn't copy. And that's the reason why it isn't able to run flawlessly and you'll get the error. You can't just copy arbitrary exe files and expect that they will work as expected. The majority of executables won't, unless they are designed to run as a stand-alone.
Steffen
Steffen
Re: how can one explain this problem of from the command line, getting wordpad to open a text file?
Thanks..
I see that
C:\carp>.\wordpad.exe <ENTER>
gives that error.
whereas this works
C:\Program Files\Windows NT\Accessories>.\wordpad<ENTER>
So that might rule out PATH and whether a filename is passed as a parameter, which helps in figuring this out.
As for your theory re DLLS.. and possibly.. other files..
You're right. I just mad a directory c:\acc and copied that directory in which wordpad.exe resides normally and with all its files, into that directory
xcopy /e "c:\Program Files\Windows NT\Accessories"\*.* c:\acc
C:\acc>dir /s/b
C:\acc\a.txt
C:\acc\en-US
C:\acc\wordpad.exe
C:\acc\WordpadFilter.dll
C:\acc\en-US\wordpad.exe.mui
And it all runs fine.
C:\acc>.\wordpad
C:\acc>.\wordpad a.txt
C:\acc>
Looks like it needed .\en-US\wordpad.exe.mui and .\WordpadFilter.dll
Thanks.. That problem had bugged me for years!
I see that
C:\carp>.\wordpad.exe <ENTER>
gives that error.
whereas this works
C:\Program Files\Windows NT\Accessories>.\wordpad<ENTER>
So that might rule out PATH and whether a filename is passed as a parameter, which helps in figuring this out.
As for your theory re DLLS.. and possibly.. other files..
You're right. I just mad a directory c:\acc and copied that directory in which wordpad.exe resides normally and with all its files, into that directory
xcopy /e "c:\Program Files\Windows NT\Accessories"\*.* c:\acc
C:\acc>dir /s/b
C:\acc\a.txt
C:\acc\en-US
C:\acc\wordpad.exe
C:\acc\WordpadFilter.dll
C:\acc\en-US\wordpad.exe.mui
And it all runs fine.
C:\acc>.\wordpad
C:\acc>.\wordpad a.txt
C:\acc>
Looks like it needed .\en-US\wordpad.exe.mui and .\WordpadFilter.dll
Thanks.. That problem had bugged me for years!
Re: how can one explain this problem of from the command line, getting wordpad to open a text file?
Well, you got it working on your machine now. However, it doesn't say anything about portability. E.g. on my machine I have a DE-de\wordpad.exe.mui. And the program has definitely dependencies on system DLLs, too. They get also updated and certain entry points may not be available depending on a particular Windows version and the libraries it ships with. So, don't rely on having your script along with a certain copy of the Accessories directory working on other machines.
Steffen
Steffen