Jump to content

WinPE 2.0 GimageX COM based HTA


geezery

Recommended Posts

p4ntb0y->

Do you know how I can get this dialog to work on Winpe v2. It works on Windows XP, but not on WinPe based system.

Here is the full sub, just make a button to call it. I also tried BrowseForFolder method and safrcdlg.CommonDialog and none of them work in Winpe. I noticed that in winpe's notepad there is a nice dialog when opening files. I wonder how I can call it?

'****************************************************************************
'* Browse Folder Button
'****************************************************************************

Sub Browse

Dim objDialog, FilePath, JustPath, objFile
Set objDialog = CreateObject("UserAccounts.CommonDialog")
objDialog.Filter = "Wim Files|*.wim|All Files|*.*"
objDialog.FilterIndex = 1
objDialog.InitialDir = myFilePath
FilePath = objDialog.ShowOpen
If FilePath = 0 Then
Exit Sub
Else

FilePath = objDialog.FileName
Set objFile = objFSO.GetFile(FilePath)
MyFilePath = objFSO.GetParentFolderName(FilePath) & "\"
Window_Onload
End If
End Sub

Solutionone ->

Here is the code for the diskpart.

If you find a way to make it readable that would be nice. Maybe you can try to Replace " " empty chars with vbTab or something:)

Sub Volumes
Dim oExec,OShell, list
Set oShell = CreateObject("WScript.Shell")
Set oExec = oShell.Exec("diskpart")
oExec.StdIn.Write "list volume" & VbCrLf
oExec.StdIn.Write "exit" & VbCrLf
list = Trim(OExec.StdOut.ReadAll)
msgbox(list)
End Sub

I'll try to find time to test this on Vistape, but I would first like to get some more features working.

Link to comment
Share on other sites


powaking->

Can you make a test in VistaPe?

Copy this code to notepad and change the filename.wim to your wim filename. Then Save it to same folder where the wim is i. e. test.vbs

CAll Volumes

Sub Volumes
Dim oExec,OShell, list
Set oShell = CreateObject("WScript.Shell")
Set oExec = oShell.Exec("imagex /info filename.wim") 'Change filename.wim to your wim filename
list = Trim(OExec.StdOut.ReadAll)
msgbox(list)
End Sub

Execute the script. You should get a msgbox containing the wim info. Try this in the VistaPE.

Link to comment
Share on other sites

It seems that everything works, but suddenly, I realized the background image is gone!

Below is what I have, Geezrey, you used to put in the older version:

<Body background="pe.jpg">

that no longer works (I just have a grey background). Then I modify your lines as follows:

<BODY>

<DIV id=bg>

img src="e:\pe.jpg">

</DIV>

What happens is I have the image at the top of the screen, and the selection comes below the image, not in the image. Do you know why?

thx

Link to comment
Share on other sites

powaking->

Can you make a test in VistaPe?

Copy this code to notepad and change the filename.wim to your wim filename. Then Save it to same folder where the wim is i. e. test.vb script: test.vbs

Tried it but got this error:

Line: 6

Char: 1

Error: The system cannot find the file specified

Code: 800700002

Source: WshShell.Exec

I even issued a cscript //H:WScript for giggles and got the same results.

BUT

I then relealized I hadn't copied the required wim files into the system32. Once I did that then I got the msgbox displaying the WIMs information. So looks like we are heading in the right direction.

Now just need to make a plugin for Vistape to copy these files to the system32 folder (so I don't have to manually do it each and every time).

Edit:

If I add this:

Do While Not oExec.StdOut.AtEndOfStream

sReadLine = oExec.StdOut.ReadLine

pos = Instr(1, sReadLine, "<DESCRIPTION>", 1)

if pos = 0 then

else

msgbox pos

end if

loop

To the Test.vbs all I get is 5 for the value of pos.

Edit #2: (Sorry but I think this is it and we can work from here)

This works. It displays the Image number, description and name

CAll Volumes

Redim strNames(0)

Redim strIndx(0)

Redim strDesc(0)

Sub Volumes

Dim oExec,OShell, list

Set oShell = CreateObject("WScript.Shell")

Set oExec = oShell.Exec("imagex.exe /info i:\vistape\MyWim.wim")

Do While Not oExec.StdOut.AtEndOfStream

sReadLine = oExec.StdOut.ReadLine

pos = Instr(1, sReadLine, "<NAME>", 1)

pos2 = Instr(1, sReadLine, "<IMAGE ", 1)

pos3= Instr(1, sReadLine, "<DESCRIPTION>", 1)

If pos2 > 0 Then

i = i + 1

Redim Preserve strIndx(i)

Redim Preserve strNames(i)

Redim Preserve strDesc(i)

strDesc(i) = "NO DESCRIPTION"

tmpStr1 = Right(sReadLine, Len(sReadLine) - (pos2 + 13))

strIndx(i) = Left(tmpStr1, Len(tmpStr1) -3) 'increased to 3 to remove the additional "

msgbox strIndx(i)

End If

If pos > 0 Then

tmpStr1 = Right(sReadLine, Len(sReadLine) - (pos + 5))

strNames(i) = Left(tmpStr1, Len(tmpStr1) -8)

msgbox strNames(i)

End If

If pos3 > 0 Then

tmpStr1 = Right(sReadLine, Len(sReadLine) - (pos3 + 12))

strDesc(i) = Left(tmpStr1, Len(tmpStr1) -15)

msgbox strDesc(i)

End If

loop

End Sub

When I incorporated this into your hta I still don't get the information in the hta.

Edited by powaking
Link to comment
Share on other sites

p4ntb0y->

Do you know how I can get this dialog to work on Winpe v2. It works on Windows XP, but not on WinPe based system.

Here is the full sub, just make a button to call it. I also tried BrowseForFolder method and safrcdlg.CommonDialog and none of them work in Winpe. I noticed that in winpe's notepad there is a nice dialog when opening files. I wonder how I can call it?

'****************************************************************************
'* Browse Folder Button
'****************************************************************************

Sub Browse

Dim objDialog, FilePath, JustPath, objFile
Set objDialog = CreateObject("UserAccounts.CommonDialog")
objDialog.Filter = "Wim Files|*.wim|All Files|*.*"
objDialog.FilterIndex = 1
objDialog.InitialDir = myFilePath
FilePath = objDialog.ShowOpen
If FilePath = 0 Then
Exit Sub
Else

FilePath = objDialog.FileName
Set objFile = objFSO.GetFile(FilePath)
MyFilePath = objFSO.GetParentFolderName(FilePath) & "\"
Window_Onload
End If
End Sub

Have you taken a look here?

http://www.visualbasicscript.com/m_36250/tm.htm

Link to comment
Share on other sites

I hardcoded this line to the hta file:

Set oExec = oShell.Exec("imagex.exe /info " + strFile)

to this

Set oExec = oShell.Exec("imagex.exe /info m:\vistape\mywim.wim")

One I did that I was able to view that wims image number and description.

It appears it has something to do with this:

Set objSel1 = window.document.getElementById("select1")

strFile = myFilepath + objSel1.options(objSel1.selectedindex).text

??

Edited by powaking
Link to comment
Share on other sites

I think I found the issue. My file path was set to M:\vistape. After doing some msgbox's I realized it should have been M:\Vistape\. Once I added the last \ it then processed my wim files. Feel sooooo stupid :wacko:

Link to comment
Share on other sites

After much thought about getting rid of the diskpart.txt file, when using the apply function. I thought of another way we would possibly do this better.

Instead of having the static diskpart.txt file, we could create the diskpart.txt file actually in the HTA dynamically line by line.

somebody could even write in some logic paths into the code, e.g. how many partitions do you wish to create, what size do you want to make the partitions. (unfortunately I'm not a scripter/programmer at all, so I found this sample code, but I'm not sure if it will work, so how to implement it)

The code could be set to delete the diskpart.txt everytime imagex.hta is refreshed.

<%
dim filesys, filetxt, getname, path
Set filesys = CreateObject("Scripting.FileSystemObject")
Set filetxt = filesys.CreateTextFile("x:\windows\system32\diskpart.txt", True)
path = filesys.GetAbsolutePathName("x:\windows\system32\diskpart.txt")
getname = filesys.GetFileName(path)
filetxt.WriteLine("Your text goes here.")
filetxt.Close
If filesys.FileExists(path) Then
Response.Write ("Your file, '" & getname & "', has been created.")
End If
%>

EDIT

Haha, I figured out the "diskpart list volume" formatting issue, I'll post my findings in the morning. Its been a long day.... I think my plan will be a pretty cool addition, and I've figured out most of the coding.

Edited by solutionone
Link to comment
Share on other sites

p4ntb0y->

Do you know how I can get this dialog to work on Winpe v2. It works on Windows XP, but not on WinPe based system.

Here is the full sub, just make a button to call it. I also tried BrowseForFolder method and safrcdlg.CommonDialog and none of them work in Winpe. I noticed that in winpe's notepad there is a nice dialog when opening files. I wonder how I can call it?

Geezery, in regards to the dialog in notepad, have a look at this page

http://msdn2.microsoft.com/en-us/library/bb397401.aspx

right at the bottom of the page is the "New Shell Functions under Vista", you will note a link to a downloadable help file that will give you the answers you need.

Link to comment
Share on other sites

Looks promising. I think I can find something there. Thank you for the tip.

About the diskpart. I think that it is possible to make it without the text files, but making the script takes a lot of time and effort.

Has anyone else had any problems with the diskpart active command, because I notices that it won't take effect on my script?

Link to comment
Share on other sites

Can you give me a detailed plan/outline, of what exactly you want the diskpart to do for the applying image system.

What prompts do you want the user to get, etc.

I know a VBscripter who has a lot of time on his hands at the moment and would be happy to make the coding for you in respect to this.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...