Skip to content

Installing software via powershell

Featured Replies

Afternoon all,

 

I am trying to setup a simple script that will determine if Drive E: exists and if so is it a CD Rom drive. Then based on that info run install command line. The if else logic seems to work but I'm having a hard time getting the install cmd to run. Any help would be greatly appreciated, I'm also open to other ways of doing this.

 

Exit code btw is 1622.

 

Cheers,

Mike

$instdir = Get-WmiObject -Class Win32_LogicalDisk |
    Where-Object {$_.DeviceID -eq "E:"}
If (!($instdir)){
    $process = start-process -filepath "setup.exe" -argumentlist '/s /v"/l*voicewarmup \"%temp%\besclientinstall.log\" INSTALLDIR=\"C:\Program Files (x86)\BigFix Enterprise\BES Client\" /qn"' -Wait -PassThru
    }

ElseIf ($instdir.DriveType -eq "5"){
    $process = start-process -filepath "setup.exe" -argumentlist '/s /v"/l*voicewarmup \"%temp%\besclientinstall.log\" INSTALLDIR=\"C:\Program Files (x86)\BigFix Enterprise\BES Client\" /qn"' -Wait -PassThru
    }

Else {
    $process = start-process -filepath "setup.exe" -argumentlist '/s /v"/l*voicewarmup \"%temp%\besclientinstall.log\" INSTALLDIR=\"E:\Program Files (x86)\BigFix Enterprise\BES Client\" /qn"' -Wait -PassThru
    }
    $process.ExitCode
  • Author

Thanks Peter. Removing the trailing backslash from the from the log path got rid of the 1622 error, but now I'm getting a 1203 error. Which appears to be:

 

ERROR_NO_NET_OR_BAD_PATH

The network path was either typed incorrectly, does not exist, or the network provider is not currently available. Please try retyping the path or contact your network administrator.

1203 (0x4B3)

  • Author

Ended up using VBS, works well.

Option Explicit
Dim objWMIService, objItem, colItems, strComputer, fso, WshShell, oExec
On Error Resume Next
strComputer = "."

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select DriveType from Win32_LogicalDisk Where DeviceID = 'E:'")

Set fso = WScript.CreateObject("Scripting.FileSystemObject")

If Not fso.DriveExists("E:") Then
	Set WshShell = WScript.CreateObject("WScript.Shell")
		Set oExec = WshShell.Exec("setup.exe /s /v""/l*voicewarmup \""%temp%\besclientinstall.log\"" INSTALLDIR=\""C:\Program Files (x86)\BigFix Enterprise\BES Client\"" /qn""")
		x = oExec.StdOut.ReadLine
		'Wscript.Echo x
 Else
	For Each objItem in colItems
	'Wscript.Echo "Description: " & objItem.Description
        'Wscript.Echo "DeviceID: " & objItem.DeviceID
        'Wscript.Echo "DriveType: " & objItem.DriveType
If objItem.DriveType = 3 Then
	Set WshShell = WScript.CreateObject("WScript.Shell")
		Set oExec = WshShell.Exec("setup.exe /s /v""/l*voicewarmup \""%temp%\besclientinstall.log\"" INSTALLDIR=\""E:\Program Files (x86)\BigFix Enterprise\BES Client\"" /qn""")
		x = oExec.StdOut.ReadLine
		'Wscript.Echo x
Else
	Set WshShell = WScript.CreateObject("WScript.Shell")
		Set oExec = WshShell.Exec("setup.exe /s /v""/l*voicewarmup \""%temp%\besclientinstall.log\"" INSTALLDIR=\""C:\Program Files (x86)\BigFix Enterprise\BES Client\"" /qn""")
		x = oExec.StdOut.ReadLine
		'Wscript.Echo x
End If

	Next
  
End If

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

Account

Navigation

Search

Search

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.