Jump to content

Need help with a vbScript


randalldale

Recommended Posts

Hey Guys,

Thanks for all you previous help. Now I need some scripting help.

I have a script that needs to apply a .WIM file but seems to freeze up for a moment and then ends and I can't fiure out why... so a fresh pair of eyes?

script:

Function Install()

Set objWShell = CreateObject("WScript.Shell")

objWShell.Run(ColDrv & "\Tools\dwait.hta")

If SYSID = "30C5" Then

'MsgBox "inside script"

'MsgBox ColDrv

objWShell.Run ("%comspec% /c imagex /apply ") & ColDrv & ("\Sources\WinXP.wim 1 c:"),0, True

ElseIf SYSID = "30C9" Then

objWShell.Run ("%comspec% /c imagex /apply ") & ColDrv & ("\Sources\WinXP.wim 2 c:"),0, True

ElseIf SYSID = "0890" Then

objWShell.Run ("%comspec% /c imagex /apply ") & ColDrv & ("\Sources\WinXP.wim 3 c:"),0, True

Else

msgbox "Could not find DVD attached to the system",vbError,"HP EUC"

End If

objWShell.Run ("%comspec% /c bootsect.exe /nt52 c: /force"), True

objWShell.Run ("wpeutil reboot")

self.close()

End Function

Ok, I'm passing in the drive letter for the value of 'ColDrv' but the system fails to apply the WIM file yet if I type 'imagex /apply e:\sources\winXP.wim 1 c:' it works fine. anyone know why then scripting fails? Also I have tried it with 'x:\windows\system32' in front of imagex but it still fails. The MsgBox's post just fine so I know I'm in the script.

Anyone have any ideas?

Thanks again for your help,

Randy

Link to comment
Share on other sites


objWShell.Run ("%comspec% /c imagex /apply ") & ColDrv & ("\Sources\WinXP.wim 1 c:"),0, True
objWShell.Run ("%comspec% /c imagex /apply ") & ColDrv & ("\Sources\WinXP.wim 2 c:"),0, True
objWShell.Run ("%comspec% /c imagex /apply ") & ColDrv & ("\Sources\WinXP.wim 3 c:"),0, True

I think your problem is your Run commands and the ()'s. I think it should be:

objWShell.Run "%comspec% /c imagex /apply " & ColDrv & "\Sources\WinXP.wim # c:",0, True

Link to comment
Share on other sites

You should also try to run the same .Run without the %comspec%. For some unknown reasons it doesn't always work on WinPe v.2 environment.

objWShell.Run "cmd /c imagex /apply " & ColDrv & "\Sources\WinXP.wim 2 c:",0, True

Link to comment
Share on other sites

Actually still failing with a error message of file not found, here is what I have...

objWShell.Run "cmd /k imagex /apply " & ColDrv & "\Sources\WinXP.wim 1 c:",1, True

also tried the following with imagex placed in the \sources folder.

objWShell.Run "cmd /k " & ColDrv & "\Sources\imagex /apply " & ColDrv & "\Sources\WinXP.wim 1 c:",1, True

also added a MsgBox ColDrv before and after the call tag and each time the correct drive is listed.

Yet if I run either one on a USB ThumbDrive is works fine but a DVD install fails... any ideas cause I'm stumped???

But the real kicker is that while typing this reply I tried runing the hta again without reboot and it works just fine.?.?... reboot and the image fails file not found.

Link to comment
Share on other sites

Are you trying to apply the image from a network share?

Try to run this before the apply function.

Function CheckConnectionStatus()

Set objFSO = CreateObject("Scripting.FileSystemObject")

if objFso.FileExists(ColDrv & "\Sources\WinXP.wim") And objFso.FileExists(ColDrv & "\Sources\imagex.exe") Then

'Do nothing, just continue and exit function

Else

MsgBox("ERROR: Files missing " & ColDrv & "\Sources\WinXP.wim" & " or " & ColDrv & "\Sources\imagex.exe")

End If

End Function

Link to comment
Share on other sites

Actually running it from a DVD-ROM drive.

'This is the code used to find the DVD-ROM drive.

'I also set a globalo variable of ColDrv

Dim ColDrv, SYSID

Function Window_Onload()

Set Fso = CreateObject("Scripting.FileSystemObject")

Set Drv = FSO.Drives

For Each StrDrv in Drv

If StrDrv.DriveType = 4 or 2 Then

If StrDrv.IsReady = True Then

If Fso.FileExits(StrDrv & "\Tools\Tools.txt") Then

ColDrv = StrvDrv

End If

End If

Else

MsgBox "Could not find DVD attached to the system", vbError

End If

Next

Using the Variable ColDrv I then try to run my install....

I seem to make it in the script but when I go to run I get a file not found error?

Do you think it is having issues with the global variable?

Function Install()

Set objWShell = CreateObject("WScript.Shell")

objWShell.Run(ColDrv & "\Tools\dwait.hta")

If SYSID = "30C5" Then

'MsgBox "inside script"

'MsgBox ColDrv

objWShell.Run "cmd /c imagex /apply " & ColDrv & "\Sources\WinXP.wim 1 c:",0, True

ElseIf SYSID = "30C9" Then

objWShell.Run "cmd /c imagex /apply " & ColDrv & "\Sources\WinXP.wim 2 c:",0, True

ElseIf SYSID = "0890" Then

objWShell.Run "cmd /c imagex /apply " & ColDrv & "\Sources\WinXP.wim 3 c:",0, True

End If

objWShell.Run "%comspec% /c bootsect.exe /nt52 c: /force",0, True

objWShell.Run "wpeutil reboot"

self.close

End Function

Thanks for looking,

Randy

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...