Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Windows Shell: Explorer vs Windows Explorer

22 Mar 2011   #1

Windows 7 Enterprise
 
 
Windows Shell: Explorer vs Windows Explorer

Im working on a small project, which isnt exactly going according to plan...

Overview:
We have some .vbs scripts which must be run before explorer.exe starts
so, the best way to do this would be to replace the windows shell with a custom program (login.exe, written in C#) by replacing the registry key, HKLM>Software>Microsoft>Windows NT>Current Version>Winlogon:Shell = login.exe

What is happening:
The user logs in using AD credentials.
Helloworld.vbs is run
When helloworld.vbs finishes and closes, Explorer.exe is run but opens as Windows Explorer, instead of the usual Shell.

Opening TaskManager (alt+ctrl+del > taskmanager) then running explorer.exe, also opens Windows explorer, instead of the Shell.

Reverting the above registry key back to explorer.exe, then logging off and on, opens the Shell.

Any ideas why?

Source code of Helloworld.vbs
Code:
wscript.echo("Hello World")
Source code of Login.exe
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace autexplorer
{
    class Program
    {
        static void Main(string[] args)
        {
            System.Diagnostics.Process myProcess = new System.Diagnostics.Process();
            myProcess.StartInfo.FileName = "wscript";
            myProcess.StartInfo.Arguments = " C:\\Windows\\Setup\\Scripts\\helloworld.vbs";
            myProcess.Start();
            myProcess.WaitForExit();
            myProcess.Close();

            System.Diagnostics.Process myProcess2 = new System.Diagnostics.Process();
            myProcess2.StartInfo.FileName = "C:\\windows\\system32\\explorer.exe";
            myProcess2.Start();

        }
    }
}
Helloworld.vbs will be rescripted for much more complex things later on. But for now, its testing only.

Im not a C# programmer, I mostly do VBScript.
But a .vbs fails to run when loaded in the above registry key.


My System SpecsSystem Spec
.

22 Mar 2011   #2

Windows 7 32 bit
 
 

Why do the .vbs script have to be run before Explorer?

I'm not big into .vbs but I'm wondering if windows scripting host has some dependencies that need Explorer such as ActiveX or similar? How about load Explorer normally, run your scripts, then kill Explorer and relaunch? Only reason I can think is that something has to be done before login. Which makes me wonder why you are taking this approach.

If it really needs to run before login then it probably needs to be implemented as a service.
My System SpecsSystem Spec
22 Mar 2011   #3

Windows 7 Enterprise
 
 

Thanks for your reply Miles,
A bit of a broader overview:
Some shell folders are redirected to the network shares. Currently done via GPO, but also testing through editing the registry keys.

Because, while connected to the network, the Novell scripts map H:\ correctly, then explorer loads, all is fine.
However in the case of a laptop user, when they take the machine home, they wont have an H:\
This is where my .vbs script works its magic. It creates a substituted H:\ and creates folders on D:\
But by the time the script runs, Explorer has already failed to find the shell folders, so 'my documents', 'music', etc are broken.

This is where I need my script to run first, to create the subst H: and folders BEFORE Explorer goes exploring for them.

When they get back to work, and reconnect to our network, once they log in they should then have their regular networked H:\ plus a D:\offlineFiles folder structure in their appropriate libraries.
This is also the reason we cannot use the C:\Users\ folders, because once they get back on the network, these are redirected and basically unusable.

The easy and dirty workaround is like you said, load Explorer, run the script, kill and restart Explorer.
However, this poses the issue that the end user will be presented with a 'broken' working desktop, which will then disappear and reappear as 'fixed'.
In our envrionment, this will not do.
It needs to be completely transparent to the end user. All they should notice is an extra couple seconds of login time.
My System SpecsSystem Spec
.


23 Mar 2011   #4

Windows 7 Enterprise
 
 

Its amazing how much clearer you can think after a trip to the bathroom.

I think I've found the solution...
The value of registry key
HKLM>Software>Microsoft>Windows NT>Current Version>Winlogon:Shell
should remain as Explorer.exe
But, the key Userinit, which by default is userinit.exe, should be the one changed to login.exe
Ref:TechNet

Login.exe has been modified to instead call userinit.exe
Code:
...
    System.Diagnostics.Process myProcess2 = new System.Diagnostics.Process();
    myProcess2.StartInfo.FileName = "C:\\windows\\system32\\userinit.exe";
    myProcess2.Start();
...
So far, it looks very promising.
After logging in, the novell scripts dialog appears as normal. That will close, and I'm presented with the "Welcome". This, as expected, takes around 3 seconds longer than in previous timings. Then Explorer loads the working desktop.

My helloworld.vbs was nowhere to be seen during the whole process.
My System SpecsSystem Spec
23 Mar 2011   #5

Windows 7 32 bit
 
 

That's interesting. With all the books like "Undocumented Windows" you would think somewhere along the line the Registry would get documented by somebody. Seems more like cryptography than system settings.

Glad you found a solution.
My System SpecsSystem Spec
Reply

 Windows Shell: Explorer vs Windows Explorer




Thread Tools




Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 12:07 AM.
Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App
  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33