Can I use a script to open a specific folder and set its attributes: menu or
not, toolbar or not, vertical and horizontal sizes, and vertical and
horizontal position on the desktop? If so, can someone point me to an
on-line resource that demonstrates this?

Thank you.
Ed

Re: Script to set folder attributes? by mr_unreliable

mr_unreliable
Mon Jan 29 12:26:37 CST 2007

Ed, good luck with this one.

My guess is that your best bet would be to use one of the
Explorer "look-alikes" coded in vb which use the windows
treeview and listview controls controls to emulate explorer.
There is vb code for some of these "look-alikes", and you
could customize the vb code to get what you want.

If you ABSOLUTELY MUST do this via script, your best bet
is probably to use the "window object" provided by the
"shell.application" object. The idea here is to launch
explorer, and then modify its appearance to suit. Here
is some code (probably by mikHar?):

--- <snip> ---
<HEAD>
<HTA:APPLICATION>
</HEAD>
<HTML>
<BODY>
<SCRIPT LANGUAGE="VBScript">
set shell = createobject("shell.application")
for each win in shell.windows
document.write "<pre>"
document.write _
"LocationURL = " & win.locationurl & "<br>" & _
"Window Type = " & typename(win) & "<br>" & _
"Document Type = " & typename(win.document) & "<br>"
if typename(win.document) = "IShellFolderViewDual" then
set f = win.document.folder
document.write " Folder = " & f.title & "<br>"
for each fi in f.items
document.write " Item = " & fi.name & "<br>"
next
end if
document.write "</pre>"
next
</SCRIPT>
</BODY>
</HTML>
--- </snip> ---

As you can see, the win.document typename is either html
or "IShellFolderViewX". From there you can access various
window properties, but unfortunately -- exactly what properties
are available is hidden (i.e., not in the typelib). So,
(three things) you are going to have to guess the names of the
properties, then see if what you want is there, and finally
determine whether the property you want is read/write.
Good Luck.

cheers, jw
____________________________________________________________

You got questions? WE GOT ANSWERS!!! ..(but,
no guarantee the answers will be applicable to the questions)


Ed wrote:
> Can I use a script to open a specific folder and set its attributes: menu or
> not, toolbar or not, vertical and horizontal sizes, and vertical and
> horizontal position on the desktop? If so, can someone point me to an
> on-line resource that demonstrates this?
>
> Thank you.
> Ed
>
>

Re: Script to set folder attributes? by Keith

Keith
Mon Jan 29 13:05:34 CST 2007

Are you wanting to manipulate a folder window as it's displayed? Or are you wanting to modify its
saved view settings?

--
Good Luck,

Keith
Microsoft MVP [Windows XP Shell/User]


"Ed" <ed_millis@NO_SPAM.yahoo.com> wrote in message news:u8jPS78QHHA.4276@TK2MSFTNGP02.phx.gbl...
> Can I use a script to open a specific folder and set its attributes: menu or not, toolbar or not,
> vertical and horizontal sizes, and vertical and horizontal position on the desktop? If so, can
> someone point me to an on-line resource that demonstrates this?
>
> Thank you.
> Ed
>


Re: Script to set folder attributes? by Ed

Ed
Mon Jan 29 14:28:24 CST 2007

Keith:

I'm wanting to cause a specific folder to open and display in the same way
into the same position every time I run the script (if such a thing is
reasonably possible). I do not care if these settings are ever saved, and
these settings will not be used for any other folder (unless included in the
code). This is a folder of programs and shortcuts that is very useful
during certain operations, but it's a real pain to open the folder,
customize the view, and position it exactly so every time I want to use it.
If I could simply launch a script (alternatively a VB6 program) to make all
this happen by code, life would be good again! (BTW, I'm using WinXP sp2.)

Ed

"Keith Miller MVP" <k.miller79@verizon.net> wrote in message
news:Oc5j2h9QHHA.3316@TK2MSFTNGP02.phx.gbl...
> Are you wanting to manipulate a folder window as it's displayed? Or are
> you wanting to modify its saved view settings?
>
> --
> Good Luck,
>
> Keith
> Microsoft MVP [Windows XP Shell/User]
>
>
> "Ed" <ed_millis@NO_SPAM.yahoo.com> wrote in message
> news:u8jPS78QHHA.4276@TK2MSFTNGP02.phx.gbl...
>> Can I use a script to open a specific folder and set its attributes: menu
>> or not, toolbar or not, vertical and horizontal sizes, and vertical and
>> horizontal position on the desktop? If so, can someone point me to an
>> on-line resource that demonstrates this?
>>
>> Thank you.
>> Ed
>>
>



Re: Script to set folder attributes? by Ayush

Ayush
Mon Jan 29 15:20:50 CST 2007

Replied to [mr_unreliable]s message :
> <HTML>
> <HEAD>
> </HEAD>
>
> <BODY>
> <SCRIPT LANGUAGE="VBScript">
> set shell = createobject("shell.application")
> for each win in shell.windows
> document.write "<pre>"
> document.write _
> "LocationURL = " & win.locationurl & "<br>" & _
> "Window Type = " & typename(win) & "<br>" & _
> "Document Type = " & typename(win.document) & "<br>"
> if typename(win.document) = "IShellFolderViewDual" then
> set f = win.document.folder
> document.write " Folder = " & f.title & "<br>"
> for each fi in f.items
> document.write " Item = " & fi.name & "<br>"
> next
> end if
> document.write "</pre>"
> next
> </SCRIPT>
> </BODY>
> </HTML>



Where is all this explained (properties, methods like document.folder, name,
locationURL, locationName) ?



--
â?? Ayush
-------------
Search - www.Google.com | Wikipedia - http://en.wikipedia.org
Snip your long urls - http://snipurl.com/
-------------

Re: Script to set folder attributes? by Ayush

Ayush
Mon Jan 29 15:59:43 CST 2007

Replied to [Ed]s message :
> Keith:
>
> I'm wanting to cause a specific folder to open and display in the same way
> into the same position every time I run the script (if such a thing is
> reasonably possible). I do not care if these settings are ever saved, and
> these settings will not be used for any other folder (unless included in the
> code). This is a folder of programs and shortcuts that is very useful
> during certain operations, but it's a real pain to open the folder,
> customize the view, and position it exactly so every time I want to use it.
> If I could simply launch a script (alternatively a VB6 program) to make all
> this happen by code, life would be good again! (BTW, I'm using WinXP sp2.)
>


set wsHl= CreateObject("WScript.Shell")
set shA= CreateObject("Shell.Application")
wsHl.Run "explorer.exe C:\Windows",0,true

set lastWin = shA.Windows.Item(shA.Windows.Count-1)

'lastWin.fullscreen = true

lastWin.Width = 800 : lastWin.Height = 600
lastWin.left = 0 : lastWin.top = 0
lastWin.ToolBar = false : lastWin.StatusBar = false
lastWin.Visible = true


The properties of shellApp.window object are similar to the open method of html
(features argument)


--
â?? Ayush
-------------
Search - www.Google.com | Wikipedia - http://en.wikipedia.org
Snip your long urls - http://snipurl.com/
-------------

Re: Script to set folder attributes? by Ed

Ed
Mon Jan 29 16:33:48 CST 2007

Thank you very much, Ayush. I greatly appreciate the help.

Ed

"Ayush" <"ayushmaan.j[aatt]gmail.com"> wrote in message
news:%23WtFtD$QHHA.924@TK2MSFTNGP06.phx.gbl...
> Replied to [Ed]s message :
>> Keith:
>>
>> I'm wanting to cause a specific folder to open and display in the same
>> way into the same position every time I run the script (if such a thing
>> is reasonably possible). I do not care if these settings are ever saved,
>> and these settings will not be used for any other folder (unless included
>> in the code). This is a folder of programs and shortcuts that is very
>> useful during certain operations, but it's a real pain to open the
>> folder, customize the view, and position it exactly so every time I want
>> to use it. If I could simply launch a script (alternatively a VB6
>> program) to make all this happen by code, life would be good again!
>> (BTW, I'm using WinXP sp2.)
>>
>
>
> set wsHl= CreateObject("WScript.Shell")
> set shA= CreateObject("Shell.Application")
> wsHl.Run "explorer.exe C:\Windows",0,true
>
> set lastWin = shA.Windows.Item(shA.Windows.Count-1)
>
> 'lastWin.fullscreen = true
>
> lastWin.Width = 800 : lastWin.Height = 600
> lastWin.left = 0 : lastWin.top = 0
> lastWin.ToolBar = false : lastWin.StatusBar = false
> lastWin.Visible = true
>
>
> The properties of shellApp.window object are similar to the open method of
> html (features argument)
>
>
> --
> ? Ayush
> -------------
> Search - www.Google.com | Wikipedia - http://en.wikipedia.org
> Snip your long urls - http://snipurl.com/
> -------------



Re: Script to set folder attributes? by Ayush

Ayush
Mon Jan 29 16:47:08 CST 2007

Replied to [Ed]s message :
> Thank you very much, Ayush. I greatly appreciate the help.
>


You are welcome Ed


--
â?? Ayush
-------------
Search - www.Google.com | Wikipedia - http://en.wikipedia.org
Snip your long urls - http://snipurl.com/
-------------

Re: Script to set folder attributes? by Ed

Ed
Mon Jan 29 17:26:07 CST 2007

I am having some problems with this. I made one change:

set wsHl= CreateObject("WScript.Shell")
set shA= CreateObject("Shell.Application")
'wsHl.Run "explorer.exe C:\Documents and Settings\MyUserName\Desktop\New
Folder",0,true '****
wsHl.Run "explorer.exe C:\Documents and Settings\MyUserName\Desktop\New
Folder",5,true '****

set lastWin = shA.Windows.Item(shA.Windows.Count-1)

'lastWin.fullscreen = true

lastWin.Width = 800 : lastWin.Height = 600
lastWin.left = 0 : lastWin.top = 0
lastWin.ToolBar = false : lastWin.StatusBar = false
lastWin.Visible = true

With 0, I didn't see anything. But the folder containing the script .vbs
file was modified as per the code!
With 5, the correct folder at least opens. But it's not affected by the
rest of the code. Upon closing out, I have an error message box:
Line 10 ("lastWin.Width etc")
Error Number 800A01A8
Object required: lastWin

Any hints?

Ed

"Ayush" <"ayushmaan.j[aatt]gmail.com"> wrote in message
news:%23lOqKe$QHHA.2076@TK2MSFTNGP05.phx.gbl...
> Replied to [Ed]s message :
>> Thank you very much, Ayush. I greatly appreciate the help.
>>
>
>
> You are welcome Ed
>
>
> --
> ? Ayush
> -------------
> Search - www.Google.com | Wikipedia - http://en.wikipedia.org
> Snip your long urls - http://snipurl.com/
> -------------



Re: Script to set folder attributes? by Ayush

Ayush
Tue Jan 30 00:59:03 CST 2007

Replied to [Ed]s message :
> I am having some problems with this. I made one change:
>
> set wsHl= CreateObject("WScript.Shell")
> set shA= CreateObject("Shell.Application")
> 'wsHl.Run "explorer.exe C:\Documents and Settings\MyUserName\Desktop\New
> Folder",0,true '****
> wsHl.Run "explorer.exe C:\Documents and Settings\MyUserName\Desktop\New
> Folder",5,true '****


> I am having some problems with this.


That's because you are trying to run two windows, but the code only sets the
attributes (whatever you call it) of only the last opened window.. this code will
work (you can open as many windows as you want) :

set wsHl= CreateObject("WScript.Shell")
set shA= CreateObject("Shell.Application")

Run "C:\FProps",0
Run "C:\Documents and Settings\Ayush",0


Sub Run (path,winStyle)
wsHl.Run "explorer.exe " & path,winStyle,True

set lastWin = shA.Windows.Item(shA.Windows.Count-1)
lastWin.Width = 800 : lastWin.Height = 600
lastWin.left = 0 : lastWin.top = 0
lastWin.ToolBar = false : lastWin.StatusBar = False
lastWin.Visible = True
End Sub


--
â?? Ayush
-------------
Search - www.Google.com | Wikipedia - http://en.wikipedia.org
Snip your long urls - http://snipurl.com/
-------------

Re: Script to set folder attributes? by Ed

Ed
Tue Jan 30 07:43:00 CST 2007

Ayush:
> That's because you are trying to run two windows, but the code only sets
> the attributes (whatever you call it) of only the last opened window..

The change I made was to comment out
'wsHl.Run "explorer.exe C:\Documents and
Settings\MyUserName\Desktop\New
Folder",0,true '****
and use instead
wsHl.Run "explorer.exe C:\Documents and Settings\MyUserName\Desktop\New
Folder",5,true '****
because the 0 did not let me see the folder, whereas the 5 (which I got from
the Help file on the Windows collection) made that window active and
visible.

I'm sorry if I'm sonfusing you with this. I'm very new at scripts and
working with Windows objects - usually I stay in VBA with Word and Excel
objects. So when the script went through
set lastWin = shA.Windows.Item(shA.Windows.Count-1)
but got to
lastWin.Width = 800 : lastWin.Height = 600
and returned the error that there was no lastWin object, I wasn't sure how
to check that or fix it.

Ed

"Ayush" <"ayushmaan.j[aatt]gmail.com"> wrote in message
news:O60CLxDRHHA.1212@TK2MSFTNGP03.phx.gbl...
> Replied to [Ed]s message :
>> I am having some problems with this. I made one change:
>>
>> set wsHl= CreateObject("WScript.Shell")
>> set shA= CreateObject("Shell.Application")
>> 'wsHl.Run "explorer.exe C:\Documents and Settings\MyUserName\Desktop\New
>> Folder",0,true '****
>> wsHl.Run "explorer.exe C:\Documents and Settings\MyUserName\Desktop\New
>> Folder",5,true '****
>
>
>> I am having some problems with this.
>
>
> That's because you are trying to run two windows, but the code only sets
> the attributes (whatever you call it) of only the last opened window..
> this code will work (you can open as many windows as you want) :
>
> set wsHl= CreateObject("WScript.Shell")
> set shA= CreateObject("Shell.Application")
>
> Run "C:\FProps",0
> Run "C:\Documents and Settings\Ayush",0
>
>
> Sub Run (path,winStyle)
> wsHl.Run "explorer.exe " & path,winStyle,True
>
> set lastWin = shA.Windows.Item(shA.Windows.Count-1)
> lastWin.Width = 800 : lastWin.Height = 600
> lastWin.left = 0 : lastWin.top = 0
> lastWin.ToolBar = false : lastWin.StatusBar = False
> lastWin.Visible = True
> End Sub
>
>
> --
> ? Ayush
> -------------
> Search - www.Google.com | Wikipedia - http://en.wikipedia.org
> Snip your long urls - http://snipurl.com/
> -------------



Re: Script to set folder attributes? by Ayush

Ayush
Tue Jan 30 14:26:30 CST 2007

Replied to [Ed]s message :
> because the 0 did not let me see the folder, whereas the 5 (which I got from
> the Help file on the Windows collection) made that window active and
> visible.
>

But 0 works for me.. 0 makes the window invisible and "lastWin.Visible = True" makes
it visible again.


> I'm sorry if I'm sonfusing you with this. I'm very new at scripts and
> working with Windows objects - usually I stay in VBA with Word and Excel
> objects. So when the script went through
> set lastWin = shA.Windows.Item(shA.Windows.Count-1)
> but got to
> lastWin.Width = 800 : lastWin.Height = 600
> and returned the error that there was no lastWin object, I wasn't sure how
> to check that or fix it.
>

Try this :

set wsHl= CreateObject("WScript.Shell")
set shA= CreateObject("Shell.Application")

Run "C:\FProps",5

Sub Run (path,winStyle)
wsHl.Run path,winStyle
winTitle = Mid(path,InStrRev(path,"\")+1)
Do While wsHl.AppActivate(winTitle)
WScript.Sleep(100)
Loop
set lastWin = shA.Windows.Item(shA.Windows.Count-1)
lastWin.Width = 800 : lastWin.Height = 600
lastWin.left = 0 : lastWin.top = 0
lastWin.ToolBar = false : lastWin.StatusBar = False
lastWin.Visible = True
End Sub



--
â?? Ayush
-------------
Search - www.Google.com | Wikipedia - http://en.wikipedia.org
Snip your long urls - http://snipurl.com/
-------------

Re: Script to set folder attributes? by Ed

Ed
Tue Jan 30 14:59:33 CST 2007

It's throwing an error on
> wsHl.Run path,winStyle
"The system cannot find the file specified"

I'm probably overlooking something very stupid here - maybe I'm missing a
certain library or assignment or something??!?
I'm also using a "C:\Documents and Settings\MyUserName\ etc" file path - I
think in VB I'm supposed to do something to handle the spaces in the name (I
haven't done a VB app in so long I've forgotten) - am I supposed to do
something in a script too?

Ed

"Ayush" <"ayushmaan.j[aatt]gmail.com"> wrote in message
news:eD0EX0KRHHA.924@TK2MSFTNGP06.phx.gbl...
> Replied to [Ed]s message :
>> because the 0 did not let me see the folder, whereas the 5 (which I got
>> from the Help file on the Windows collection) made that window active and
>> visible.
>>
>
> But 0 works for me.. 0 makes the window invisible and "lastWin.Visible =
> True" makes it visible again.
>
>
>> I'm sorry if I'm sonfusing you with this. I'm very new at scripts and
>> working with Windows objects - usually I stay in VBA with Word and Excel
>> objects. So when the script went through
>> set lastWin = shA.Windows.Item(shA.Windows.Count-1)
>> but got to
>> lastWin.Width = 800 : lastWin.Height = 600
>> and returned the error that there was no lastWin object, I wasn't sure
>> how to check that or fix it.
>>
>
> Try this :
>
> set wsHl= CreateObject("WScript.Shell")
> set shA= CreateObject("Shell.Application")
>
> Run "C:\FProps",5
>
> Sub Run (path,winStyle)
> wsHl.Run path,winStyle
> winTitle = Mid(path,InStrRev(path,"\")+1)
> Do While wsHl.AppActivate(winTitle)
> WScript.Sleep(100)
> Loop
> set lastWin = shA.Windows.Item(shA.Windows.Count-1)
> lastWin.Width = 800 : lastWin.Height = 600
> lastWin.left = 0 : lastWin.top = 0
> lastWin.ToolBar = false : lastWin.StatusBar = False
> lastWin.Visible = True
> End Sub
>
>
>
> --
> ? Ayush
> -------------
> Search - www.Google.com | Wikipedia - http://en.wikipedia.org
> Snip your long urls - http://snipurl.com/
> -------------



Re: Script to set folder attributes? by Ayush

Ayush
Tue Jan 30 15:14:47 CST 2007

Replied to [Ed]s message :
> It's throwing an error on
>> wsHl.Run path,winStyle
> "The system cannot find the file specified"
>
> I'm probably overlooking something very stupid here - maybe I'm missing a
> certain library or assignment or something??!?
> I'm also using a "C:\Documents and Settings\MyUserName\ etc" file path - I
> think in VB I'm supposed to do something to handle the spaces in the name (I
> haven't done a VB app in so long I've forgotten) - am I supposed to do
> something in a script too?
>


You need quotes if the path contains spaces.. try this script :

set wsHl= CreateObject("WScript.Shell")
set shA= CreateObject("Shell.Application")

Run "C:\Documents and settings\Ayush\Local Settings\Temp\",5


Sub Run (path,winStyle)
wsHl.Run Chr(34) & path & Chr(34) ,winStyle
winTitle = Mid(path,InStrRev(path,"\")+1)
Do
WScript.Sleep(200)
Loop While wsHl.AppActivate(winTitle)
set lastWin = shA.Windows.Item(shA.Windows.Count-1)
lastWin.Width = 800 : lastWin.Height = 600
lastWin.left = 0 : lastWin.top = 0
lastWin.ToolBar = false : lastWin.StatusBar = False
lastWin.Visible = True
End Sub


--
â?? Ayush
-------------
Search - www.Google.com | Wikipedia - http://en.wikipedia.org
Snip your long urls - http://snipurl.com/
-------------

Re: Script to set folder attributes? by Ed

Ed
Tue Jan 30 17:03:37 CST 2007

Ayush, you are great! It works perfectly!! Thank you so much! I know you
had other things you could have done - I really appreciate this. Just one
question, please - is there an on-line resource where I learn about the
object you set "lastWin" to (I'm assuming it's a Window object from the
Windows collection?) and the methods? Maybe next time I can get farther on
my own and at least ask more intelligent questions!

With gratitude,
Ed

"Ayush" <"ayushmaan.j[aatt]gmail.com"> wrote in message
news:efIrVPLRHHA.1212@TK2MSFTNGP03.phx.gbl...
> Replied to [Ed]s message :
>> It's throwing an error on
>>> wsHl.Run path,winStyle
>> "The system cannot find the file specified"
>>
>> I'm probably overlooking something very stupid here - maybe I'm missing a
>> certain library or assignment or something??!?
>> I'm also using a "C:\Documents and Settings\MyUserName\ etc" file path -
>> I think in VB I'm supposed to do something to handle the spaces in the
>> name (I haven't done a VB app in so long I've forgotten) - am I supposed
>> to do something in a script too?
>>
>
>
> You need quotes if the path contains spaces.. try this script :
>
> set wsHl= CreateObject("WScript.Shell")
> set shA= CreateObject("Shell.Application")
>
> Run "C:\Documents and settings\Ayush\Local Settings\Temp\",5
>
>
> Sub Run (path,winStyle)
> wsHl.Run Chr(34) & path & Chr(34) ,winStyle
> winTitle = Mid(path,InStrRev(path,"\")+1)
> Do
> WScript.Sleep(200)
> Loop While wsHl.AppActivate(winTitle)
> set lastWin = shA.Windows.Item(shA.Windows.Count-1)
> lastWin.Width = 800 : lastWin.Height = 600
> lastWin.left = 0 : lastWin.top = 0
> lastWin.ToolBar = false : lastWin.StatusBar = False
> lastWin.Visible = True
> End Sub
>
>
> --
> ? Ayush
> -------------
> Search - www.Google.com | Wikipedia - http://en.wikipedia.org
> Snip your long urls - http://snipurl.com/
> -------------



Re: Script to set folder attributes? by Ayush

Ayush
Tue Jan 30 17:12:32 CST 2007

Replied to [Ed]s message :
> Ayush, you are great! It works perfectly!! Thank you so much! I know you
> had other things you could have done - I really appreciate this.


You are welcome .

> Just one
> question, please - is there an on-line resource where I learn about the
> object you set "lastWin" to (I'm assuming it's a Window object from the
> Windows collection?) and the methods? Maybe next time I can get farther on
> my own and at least ask more intelligent questions!
>

Oh..yeah.

Shell.App > Windows returns a WIndows Collection :
http://msdn2.microsoft.com/en-us/library/ms630310.aspx

WindowsCollection.Item returns a InternetExplorer object (i made the script using
this reference) :
http://msdn.microsoft.com/workshop/browser/webbrowser/reflist_vb.asp




--
â?? Ayush
-------------
Search - www.Google.com | Wikipedia - http://en.wikipedia.org
Snip your long urls - http://snipurl.com/
-------------

Re: Script to set folder attributes? by Ed

Ed
Tue Jan 30 17:40:39 CST 2007

Again, many thanks!
Ed

"Ayush" <"ayushmaan.j[aatt]gmail.com"> wrote in message
news:eEeOJRMRHHA.1036@TK2MSFTNGP03.phx.gbl...
> Replied to [Ed]s message :
>> Ayush, you are great! It works perfectly!! Thank you so much! I know
>> you had other things you could have done - I really appreciate this.
>
>
> You are welcome .
>
>> Just one question, please - is there an on-line resource where I learn
>> about the object you set "lastWin" to (I'm assuming it's a Window object
>> from the Windows collection?) and the methods? Maybe next time I can get
>> farther on my own and at least ask more intelligent questions!
>>
>
> Oh..yeah.
>
> Shell.App > Windows returns a WIndows Collection :
> http://msdn2.microsoft.com/en-us/library/ms630310.aspx
>
> WindowsCollection.Item returns a InternetExplorer object (i made the
> script using this reference) :
> http://msdn.microsoft.com/workshop/browser/webbrowser/reflist_vb.asp
>
>
>
>
> --
> ? Ayush
> -------------
> Search - www.Google.com | Wikipedia - http://en.wikipedia.org
> Snip your long urls - http://snipurl.com/
> -------------