MSFN Forum: Need help with a vbScript - MSFN Forum

Jump to content



Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Need help with a vbScript Can't get imagex to apply .WIM file... Rate Topic: -----

#1 User is offline   randalldale 

  • Member
  • PipPip
  • Group: Members
  • Posts: 111
  • Joined: 16-November 04

Posted 17 April 2008 - 07:10 PM

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


#2 User is offline   WreX 

  • Junior
  • Pip
  • Group: Members
  • Posts: 84
  • Joined: 26-October 07

Posted 18 April 2008 - 07:39 AM

View Postrandalldale, on Apr 17 2008, 08:10 PM, said:

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


#3 User is offline   randalldale 

  • Member
  • PipPip
  • Group: Members
  • Posts: 111
  • Joined: 16-November 04

Posted 18 April 2008 - 08:56 AM

Thanks I will give that a try and let you know...
Randy

#4 User is offline   geezery 

  • Member
  • PipPip
  • Group: Members
  • Posts: 254
  • Joined: 21-July 06

Posted 18 April 2008 - 09:12 AM

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

#5 User is offline   randalldale 

  • Member
  • PipPip
  • Group: Members
  • Posts: 111
  • Joined: 16-November 04

Posted 18 April 2008 - 05:27 PM

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.

#6 User is offline   geezery 

  • Member
  • PipPip
  • Group: Members
  • Posts: 254
  • Joined: 21-July 06

Posted 19 April 2008 - 06:33 AM

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

#7 User is offline   randalldale 

  • Member
  • PipPip
  • Group: Members
  • Posts: 111
  • Joined: 16-November 04

Posted 19 April 2008 - 09:58 PM

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

#8 User is offline   randalldale 

  • Member
  • PipPip
  • Group: Members
  • Posts: 111
  • Joined: 16-November 04

Posted 21 April 2008 - 05:59 PM

Fixed it... Duh...

Where the script is finding the CD-ROM drive I have:

ColDrv = StrvDrv

and it should be

ColDrv = StrvDrv.Path

Otherwise you get intermittent failures that can not be explained.

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2011 msfn.org
Privacy Policy