[RESOLVED] Cmd in vb and Super hidden files
I looked through the posts and though I found similar questions none quite answered what I needed. I wish to run this command from vb: attrib “filename or folder with complete path” +s +h (without quotes)
BUT I do not have a set path, as I'd like it to be a variable that I have in my vb program. How would I go about changing the exact path to the variable? Is that possible? and if not how would i ship the batch file to the other person's pc that this program will be run on? Any help and example code would be AWESOME! Its been a while since i've programmed anything, so I'm a little rusty...
Re: Cmd in vb and Super hidden files
Code:
Dim testPath As String
testPath = "the path of the file goes here"
SetAttr testPath, vbHidden + vbSystem
Re: Cmd in vb and Super hidden files
from msdn
Quote:
SetAttr Statement Example
This example uses the SetAttr statement to set attributes for a file. On the Macintosh, only the constants vbNormal, vbReadOnly, vbHidden and vbAlias are available.
SetAttr "TESTFILE", vbHidden ' Set hidden attribute.
SetAttr "TESTFILE", vbHidden + vbReadOnly ' Set hidden and read-only
' attributes.
Re: Cmd in vb and Super hidden files
I want the user to pick the path at runtime, then make that folder hidden... I have it so when the user picks the folder it is stored in a variable... Would I use that variable in the "the path of the file goes here" part of the code?
Re: Cmd in vb and Super hidden files
yes, replace the file name with the path variable, as in someluke example
Re: Cmd in vb and Super hidden files
well I just can't get it to work... I feel as though I'm missing the command to bring up cmd.exe or something. What should my code look like if I'm trying to execute the command attrib “strSelectedFolder” +s +h... It could be something simple that I'm missing, but I just don't know... its been such a long time since I've worked with vb or programming in general. The event takes place at a button click and I'm thinking I'm going to have to declare the variable selected folder in general declarations since I'm using it in a directory change event AND the button click event. I erased my code for the dos and decided to start from scratch, but now I'm just even more confused... I waited too long to apply what I was asking as I had to continue coding the next day and forgot...so my question is what should it look like?
Re: Cmd in vb and Super hidden files
Something like this.
Code:
SetAttr “filename or folder with complete path” , vbHidden + vbReadOnly ' Set hidden and read-only
Re: Cmd in vb and Super hidden files
I pasted that code in the button click event and nothing happens the folder is still visible, and there is no cmd.exe window. what am i doing wrong?
Re: Cmd in vb and Super hidden files
You're not providing the path....
"the path of the file goes here"
should be something like
"C:\FolderName"
Re: Cmd in vb and Super hidden files
hidden attribute will only hide the file/folder if the user doesnt have "Show all hidden files and folders" selected in their Folder Options.
Re: Cmd in vb and Super hidden files
Quote:
Originally Posted by RobDog888
hidden attribute will only hide the file/folder if the user doesnt have "Show all hidden files and folders" selected in their Folder Options.
I see... then my original question still stands. How do I run dos commands from my vb program? The command I wish to run make a file or folder hidden, I don't need a command to do that, just how to run the one I have using a variable that is declared in my general declarations that the user picks at run time.
The user picks a folder they wish to hide using the directory control I placed on the form, then they hit a button which hides the folder using the dos command attrib “filename or folder with complete path” +s +h (without quotes) my variable is received when the user selects their folder. So I don't have an exact path until the user selects it and it is passed to the declared variable. so my question is how do I run that command I specified in dos with my declared variable? or can it be done?
Re: Cmd in vb and Super hidden files
Re: Cmd in vb and Super hidden files
even using dos they will still show in explorer on any computer, set to show hidden and system files
here is the code, the folder property is hidden and can not be unhidden in explorer, but the folder and contents is still visible
vb Code:
p = "c:\temp"
Shell "cmd.exe /c attrib +S +H """ & p & """"
Re: Cmd in vb and Super hidden files
So if you are asking to hide a folder from the operating system but then how would it be able to keep track of it ;)
Re: Cmd in vb and Super hidden files
Why do you still want the DOS Command when SetAttr accomplishes it already? Do have a special reason for that? They just perform the same function.
Re: Cmd in vb and Super hidden files
Quote:
Originally Posted by RobDog888
So if you are asking to hide a folder from the operating system but then how would it be able to keep track of it ;)
With a change in registry to unhide the folder, that I would code in the unhide button.
Re: Cmd in vb and Super hidden files
No I mean how Windows would keep track of it with some "super" hidden attribute when it doesnt exist. Its only vbHidden which still will always be able to be shown if the user changes or already has the setting on.
Re: [RESOLVED] Cmd in vb and Super hidden files
thanks i figured it out with your help!