Click here to Skip to main content
15,881,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello All,

For a project I'm working on, I need to get a VBScript working on WinPE which allows the user to map a network drive under their domain account. The script uses the following object classes:

- wscript.network
- ScriptPW.Password
- Scripting.FileSystemObject

The problem I'm running into is that since PE is stripped down, I can't seem to identify all the dependancies that I need to include in my WIM. At this point, I'm able to get the vbscript to kick off (I have to use the syntax "cscript.exe //E:Vbscript mapNetworkDrive.vbs"), but when it gets to the code where I have the user enter their password w/out showing the keystrokes on-screen, it does display the characters. After I hit enter, the script seems to freeze the console window. Hitting Control+C does not terminate it.

Before you ask; the script does run fine in any full version of x86 Windows.

I have the following DLLs included in my WIM and they get registered upon startup:
- scriptpw.dll
- vbscript.dll
- wshom.ocx
- scrrun.dll

Does anyone have any idea what other dependancies I might be missing?

Please see my code below:

VB
Dim objNetwork, objPassword, strVolumeLabel, strRemoteShare, StdIn, StdOut, ISID, Password, fso, vlOK, path

set objNetwork = wscript.createobject("Wscript.Network")
Set objPassword = CreateObject( "ScriptPW.Password" )
Set StdIn = Wscript.StdIn
Set stdOut = WScript.StdOut
set fso = CreateObject("Scripting.FileSystemObject")

StdOut.Write "Please enter your ISID: "
ISID = StdIn.ReadLine
StdOut.Write "Please enter your Password: "
Password = objPassword.GetPassword()
stdOut.WriteLine ""
StdOut.Write "Please enter the network path you want to map: "
path = StdIn.ReadLine

vlOK = 1
do while vlOK = 1	
	StdOut.Write "Please enter the drive letter you want to use: "
	strVolumeLabel = StdIn.ReadLine

	if len(strVolumeLabel) <> 1 then
		stdout.writeline "Please enter only one letter."
		stdout.write "Please enter the drive letter you want to use: "
		strVolumeLabel = StdIn.ReadLine
	else
		if fso.DriveExists(strVolumeLabel & ":") then
			stdout.writeline "That Drive Letter is already in use."
		else
			vlOK = 0
		end if
	end if
	
loop

strvolumelabel = strvolumelabel & ":"
stdout.writeline ""
objNetwork.MapNetworkDrive strVolumeLabel, path, "False", ISID, Password

if fso.DriveExists(strVolumeLabel) then
	stdout.WriteLine "The network drive was mapped successfully."
else
	stdout.WriteLine "An error occurred when attempting to map the network drive."
end if

stdout.writeline "Press ENTER key to exit"
Do While Not WScript.StdIn.AtEndOfLine
   Input = WScript.StdIn.Read(1)
Loop


Thanks in advance for any help!
Posted
Updated 16-Oct-16 18:16pm

1 solution

you have add 3 Package
1. WinPE-HTA.cab
2.WinPE-Scripting.cab
3.WinPE-Wmi.cab


To add Hta pakege follow the link of MSDN
WinPE: Add packages (Optional Components Reference)[^]

other two as like MSDN link but change the Package name

thanks .....

note: package have two version 64 and 32 bit as per your requirement add you packages
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900