I need to programmatically mount a WebDAV volume in Windows using C, and I think I'm going to use system() to achieve this (via the 'net use' command)... However, since net use requires that the password be written in plain text, I just wanted to make sure there's no logging of commands run in the Windows command line shell... I know in Mac OS X and Linux in some circumstances commands can be logged in the file .bash_history, so I thought maybe something similar was going on in Windows. I don't think so though, since nothing showed up on Google.
The shell has a history, but it's only stored in memory not a log on disk. That said, it could end up in the swap file and open to (slightly non-trivial) discovery. Then again, if you did the connection directly in your own program using something like
WNetAddConnection2, it could end up in the swap file anyway.
It might be better to use the 'CreateProcess' and redirect the input and output to your code, and feed it into it by writing to stdin (which would be redirected to the 'Net use' command), and read the output, in that way, the password input would not be logged... this is in theory....I am not 100% confident if the popen implementation exists....as it's POSIX compliant and not found in standard C...it exists in the *nix world...
Edit: Good news, I found some code that emulates a popen using a wrapper around CreateProcess, just thought it might help. The code would need to be tweaked a bit...It's GPL v2 licence..so..something to bear in mind...
Hope this helps, Best regards, Tom.
Not an answer to your question, but instead of
net use check WNetAddConnection2 win32 function
The windows command shell doesn't have any built in command logging, it uses an external command for that (doskey), I don't think that a command prompt from a
system() command has doskey installed, but if you want to be certain, use system() to execute
and it will output the command line history for that instance of the command prompt.
A normal command interface doesn't have a history unless you explicitly active it (but I can't remember this command being available , last I checked was in the DOS/windows 95 days). Visual studio command prompt does have a history though -- but I doubt its retained when you close the prompt.