Skip to content
View in the app

A better way to browse. Learn more.

MSFN

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Need help with a vbScript

Featured Replies

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

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

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

  • Author

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.

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

  • Author

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

  • Author

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.

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.