Windows Shell: Explorer vs Windows Explorer

xarden

New member
Guru
Local time
8:22 AM
Messages
905
Location
Auckland
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 Computer

OS
Windows 7 Enterprise
CPU
Intel Pentium Dual E2200 @2.2GHz
Motherboard
Gigabyte II-G31
Memory
4GB
Graphics Card(s)
Palit GForce 9500GT 1GB
Sound Card
onBoard
Hard Drives
WesternDigital: 250GB + 1TB + 1TB + 2TB
PSU
450W
Case
CoolerMaster CM690
Cooling
Corsair H50
Mouse
Logitech MX518
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 Computer

Computer Manufacturer/Model Number
HP Media Center
OS
Windows 7 32 bit
CPU
AMD 5200+ dual core
Memory
2 GB
Graphics Card(s)
NVidia GeForce 6150SE 128 MB
Monitor(s) Displays
CRT
Screen Resolution
1280x1024
Hard Drives
500 GB Sata internal :

SIIG USB 3.0 docking stations w/WD Caviar Black 6 Gb/s drives
Keyboard
PS/2
Mouse
PS/2 Wheel Mouse
Other Info
SIIG USB 3.0 PCIexpress card.
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 Computer

OS
Windows 7 Enterprise
CPU
Intel Pentium Dual E2200 @2.2GHz
Motherboard
Gigabyte II-G31
Memory
4GB
Graphics Card(s)
Palit GForce 9500GT 1GB
Sound Card
onBoard
Hard Drives
WesternDigital: 250GB + 1TB + 1TB + 2TB
PSU
450W
Case
CoolerMaster CM690
Cooling
Corsair H50
Mouse
Logitech MX518
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\\[I]userinit.exe[/I]";
    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 Computer

OS
Windows 7 Enterprise
CPU
Intel Pentium Dual E2200 @2.2GHz
Motherboard
Gigabyte II-G31
Memory
4GB
Graphics Card(s)
Palit GForce 9500GT 1GB
Sound Card
onBoard
Hard Drives
WesternDigital: 250GB + 1TB + 1TB + 2TB
PSU
450W
Case
CoolerMaster CM690
Cooling
Corsair H50
Mouse
Logitech MX518
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 Computer

Computer Manufacturer/Model Number
HP Media Center
OS
Windows 7 32 bit
CPU
AMD 5200+ dual core
Memory
2 GB
Graphics Card(s)
NVidia GeForce 6150SE 128 MB
Monitor(s) Displays
CRT
Screen Resolution
1280x1024
Hard Drives
500 GB Sata internal :

SIIG USB 3.0 docking stations w/WD Caviar Black 6 Gb/s drives
Keyboard
PS/2
Mouse
PS/2 Wheel Mouse
Other Info
SIIG USB 3.0 PCIexpress card.
Back
Top