|
-
Jan 9th, 2009, 05:06 PM
#1
Thread Starter
New Member
[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...
-
Jan 9th, 2009, 05:59 PM
#2
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
_____________________________________________________________________
----If this post has helped you. Please take time to Rate it.
----If you've solved your problem, then please mark it as RESOLVED from Thread Tools.

-
Jan 9th, 2009, 06:07 PM
#3
Re: Cmd in vb and Super hidden files
from msdn
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.
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Jan 9th, 2009, 06:12 PM
#4
Thread Starter
New Member
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?
-
Jan 9th, 2009, 09:42 PM
#5
Re: Cmd in vb and Super hidden files
yes, replace the file name with the path variable, as in someluke example
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Jan 10th, 2009, 12:28 PM
#6
Thread Starter
New Member
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?
-
Jan 10th, 2009, 12:42 PM
#7
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
-
Jan 10th, 2009, 12:58 PM
#8
Thread Starter
New Member
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?
-
Jan 10th, 2009, 02:37 PM
#9
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"
_____________________________________________________________________
----If this post has helped you. Please take time to Rate it.
----If you've solved your problem, then please mark it as RESOLVED from Thread Tools.

-
Jan 10th, 2009, 03:23 PM
#10
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.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 10th, 2009, 03:52 PM
#11
Thread Starter
New Member
Re: Cmd in vb and Super hidden files
 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?
-
Jan 10th, 2009, 03:57 PM
#12
Re: Cmd in vb and Super hidden files
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 10th, 2009, 08:07 PM
#13
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 & """"
Last edited by westconn1; Jan 10th, 2009 at 08:23 PM.
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Jan 10th, 2009, 10:05 PM
#14
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
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 10th, 2009, 11:52 PM
#15
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.
-
Jan 11th, 2009, 05:21 PM
#16
Thread Starter
New Member
Re: Cmd in vb and Super hidden files
 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.
-
Jan 11th, 2009, 05:36 PM
#17
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.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 12th, 2009, 07:18 PM
#18
Thread Starter
New Member
Re: [RESOLVED] Cmd in vb and Super hidden files
thanks i figured it out with your help!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|