• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Finer control over variable execution

?

=?Utf-8?B?U0RM?=

#1
Greetings,

I often need to generate images of various versions of Microsoft Windows
containing the latest updates slipstreamed into the media, so when the
company I work for deploys images to machines, they are already 100%
up-to-date and secure, allowing for immediate use by the user with no
downtime while the machines updates through Windows/Microsoft Update or the
local WSUS Server.

I had some spare time a few days ago, and am attempting to create a
PowerShell script that automatically generates these images, so I only need
dump the update executable into the respective directory, and it is
automatically added to the latest image. However, I am having trouble parsing
arguments to the image program through the script. The following is an
excerpt:

"Preparing to generate image..."
$IGS_CDImage_Path = "..\Tools\cdimage.exe "
$IGS_CDImage_VolumeLabel = "-lWXP-PRO-JUN06"
$IGS_CDImage_TimeStamp_Raw = get-date -uformat "%m/%d/%Y/%H/%M/%S "
$IGS_CDImage_TimeStamp = "-t" + $IGS_CDImage_TimeStamp_Raw
$IGS_CDImage_BootSector = "-b `"..\src\bootsector.bin`" -p0 -e "
$IGS_CDImage_CmdOptions = "-g -h -j1 -x -o -w1 -m "
$IGS_CDImage_SourceRoot = "`"..\src`" "
$IGS_CDImage_TargetFile = "`"$IGS_Dir" + "\" + "$IGS_File`""
$IGS_CDImage_Execute = $IGS_CDImage_Path + $IGS_CDImage_VolumeLabel +
$IGS_CDImage_TimeStamp + $IGS_CDImage_BootSector + $IGS_CDImage_CmdOptions +
$IGS_CDImage_SourceRoot + $IGS_CDImage_TargetFile
""
"Initiating image creation..."
$IGS_CDImage_Execute
& $IGS_CDImage_Execute

However, this always results in an error:
'..\Tools\cdimage.exe -lWXP_PRO_JUN06 -t08/26/2006/20/41/15 -b
"..\src\bootsector.bin" -p0 -e -g -h -j1 -x -o -w1 -m "..\src" "C:\\Windows
XP Pro - June 2006 Update.iso"' is not recognized as a cmdlet, function,
operable program, or script file. At X:\Scripts\Windows XP Image
Generation.ps1:
44 char:2
+ & <<<< $IGS_CDImage_Execute

I am at something of a loss as to the cause of this error, but I suspect I
am making some errors in not specifying with enough detail how to execute the
output. However, the contents of the $IGS_CDImage_Execute variable at
execution appear fine:
...\Tools\cdimage.exe -lWXP_PRO_JUN06 -t08/26/2006/20/41/15 -b
"..\src\bootsector.bin" -p0 -e -g -h -j1 -x -o -w1 -m "..\src" "C:\\Windows
XP Pro - June 2006 Update.iso"

Ant help would be greatly appreciated,

-SDL
 

My Computer

J

Jouko Kynsijärvi

#2
SDL wrote:
> & $IGS_CDImage_Execute


> However, this always results in an error:
> '..\Tools\cdimage.exe -lWXP_PRO_JUN06 -t08/26/2006/20/41/15 -b
> "..\src\bootsector.bin" -p0 -e -g -h -j1 -x -o -w1 -m "..\src"
> "C:\\Windows XP Pro - June 2006 Update.iso"' is not recognized as a
> cmdlet, function, operable program, or script file.


Try this instead of "& $IGS_CDImage_Execute":

Invoke-Expression $IGS_CDImage_Execute

# here PS is interpreting the _whole string_ as a cmdlet/function etc. name:
$x = 'notepad a.txt'; &$x
'notepad a.txt' is not recognized as a cmdlet, function, operable program,
or script file.

# with invoke-expression PS is actually parsing the string:
$x = 'notepad a.txt'; invoke-expression $x
 

My Computer

J

Jeffrey Snover [MSFT]

#3

My Computer

?

=?Utf-8?B?U0RM?=

#4
Greetings again,

Thanks to both of you for the help, the 'invoke-expression' cmdlet is
exactly what I was looking for. However, I'm still having issues with the
command string being interpreted incorrectly. For example:

'"..\Tools\cdimage.exe" -lWXP_PRO_JUN06 -t08/26/2006/20/41/15
-b"..\src\bootsector.bin" -p0 -e -g -h -j1 -x -o -w1 -m "..\src" "C:\\Windows
XP Pro - June 2006 Update.iso"'
Invoke-Expression : You must provide a value expression on the right-hand
side of the '-' operator. At X:\Scripts\Windows XP Image
Generation.ps1:
44 char:18
+ invoke-expression <<<< $IGS_CDImage_Execute

This points to the '.' in the cdimage.exe part of the string. Simply put,
all I want is the "..\Tools\cdimage.exe" component to execute the cdimage
executable, and the rest of the string be passed "raw" and unmodified
directly to the cdimage executable for it to interpret itself. Thanks again
for the help provided.

-SDL
"Jeffrey Snover [MSFT]" wrote:

> Jouko has it right.
> & says "use the next token as the NAME of the thing to execute"
>
> --
> Jeffrey Snover [MSFT]
> Windows PowerShell/Aspen Architect
> Microsoft Corporation
> This posting is provided "AS IS" with no warranties, no confers rights.
> Visit the Windows PowerShell Team blog at:
> http://blogs.msdn.com/PowerShell
> Visit the Windows PowerShell ScriptCenter at:
> http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx
>
>
>
 

My Computer

?

=?Utf-8?B?ZHJlZXNjaGtpbmQ=?=

#5
I did not try this out, but may be this will work:

###############################################
$StartInfo = new-object System.Diagnostics.ProcessStartInfo
$StartInfo.FileName = '..\Tools\cdimage.exe'
$StartInfo.Arguments = '-lWXP_PRO_JUN06 -t08/26/2006/20/41/15
-b"..\src\bootsector.bin" -p0 -e -g -h -j1 -x -o -w1 -m "..\src" "C:\\Windows
XP Pro - June 2006 Update.iso"'
$StartInfo.WorkingDirectory = 'C:\' #fill in the correct directory here
$StartInfo.LoadUserProfile = $true
$StartInfo.UseShellExecute = $true
[System.Diagnostics.Process]::Start($StartInfo)
###############################################

Hope that helps.

BTW: It might be easier to use only absolute path names and (if feasible)
fewer arguments first, so that you can eliminate possible sources of error.
This might help to localize the cause of failure.

--
greetings
dreeschkind

"SDL" wrote:

> Greetings again,
>
> Thanks to both of you for the help, the 'invoke-expression' cmdlet is
> exactly what I was looking for. However, I'm still having issues with the
> command string being interpreted incorrectly. For example:
>
> '"..\Tools\cdimage.exe" -lWXP_PRO_JUN06 -t08/26/2006/20/41/15
> -b"..\src\bootsector.bin" -p0 -e -g -h -j1 -x -o -w1 -m "..\src" "C:\\Windows
> XP Pro - June 2006 Update.iso"'
> Invoke-Expression : You must provide a value expression on the right-hand
> side of the '-' operator. At X:\Scripts\Windows XP Image
> Generation.ps1:
> 44 char:18
> + invoke-expression <<<< $IGS_CDImage_Execute
>
> This points to the '.' in the cdimage.exe part of the string. Simply put,
> all I want is the "..\Tools\cdimage.exe" component to execute the cdimage
> executable, and the rest of the string be passed "raw" and unmodified
> directly to the cdimage executable for it to interpret itself. Thanks again
> for the help provided.
>
> -SDL
> "Jeffrey Snover [MSFT]" wrote:
>
> > Jouko has it right.
> > & says "use the next token as the NAME of the thing to execute"
> >
> > --
> > Jeffrey Snover [MSFT]
> > Windows PowerShell/Aspen Architect
> > Microsoft Corporation
> > This posting is provided "AS IS" with no warranties, no confers rights.
> > Visit the Windows PowerShell Team blog at:
> > http://blogs.msdn.com/PowerShell
> > Visit the Windows PowerShell ScriptCenter at:
> > http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx
> >
> >
> >
 

My Computer

?

=?Utf-8?B?U0RM?=

#6
Hello again dreeschkind :)

Your method does indeed work, there are no longer any problems with execution!

However, I have one last minor issue, purely aesthetic, but using this
method the process is launched in a new window (cmd.exe) and instantly closes
upon completion. I guess there are two possibilities here:

1. My first preference would be a method to simply run the process inside
the PowerShell window(process), or failing that, background the cdimage.exe
process but redirect all of it's output to the PowerShell process, which is
almost just as good. I took a look at the relevant references in the MSDN
library:
http://msdn2.microsoft.com/en-us/library/system.diagnostics.processstartinfo_properties.aspx.
Would the Redirect* objects be of use here? Sorry, but I'm not a programmer ;)

2. Failing that, I guess the next best option would be to simply have the
process window automatically close on the completion of the process, this
could be done through the "pause" command, but I'm not sure how or if that
could be parsed with the process execution to ensure it runs immediately
following the completion of the cdimage.exe process.

Thanks for your help dreeschkind, it is very much appreciated.

-SDL

"dreeschkind" wrote:

> I did not try this out, but may be this will work:
>
> ###############################################
> $StartInfo = new-object System.Diagnostics.ProcessStartInfo
> $StartInfo.FileName = '..\Tools\cdimage.exe'
> $StartInfo.Arguments = '-lWXP_PRO_JUN06 -t08/26/2006/20/41/15
> -b"..\src\bootsector.bin" -p0 -e -g -h -j1 -x -o -w1 -m "..\src" "C:\\Windows
> XP Pro - June 2006 Update.iso"'
> $StartInfo.WorkingDirectory = 'C:\' #fill in the correct directory here
> $StartInfo.LoadUserProfile = $true
> $StartInfo.UseShellExecute = $true
> [System.Diagnostics.Process]::Start($StartInfo)
> ###############################################
>
> Hope that helps.
>
> BTW: It might be easier to use only absolute path names and (if feasible)
> fewer arguments first, so that you can eliminate possible sources of error.
> This might help to localize the cause of failure.
>
> --
> greetings
> dreeschkind
>
> "SDL" wrote:
>
> > Greetings again,
> >
> > Thanks to both of you for the help, the 'invoke-expression' cmdlet is
> > exactly what I was looking for. However, I'm still having issues with the
> > command string being interpreted incorrectly. For example:
> >
> > '"..\Tools\cdimage.exe" -lWXP_PRO_JUN06 -t08/26/2006/20/41/15
> > -b"..\src\bootsector.bin" -p0 -e -g -h -j1 -x -o -w1 -m "..\src" "C:\\Windows
> > XP Pro - June 2006 Update.iso"'
> > Invoke-Expression : You must provide a value expression on the right-hand
> > side of the '-' operator. At X:\Scripts\Windows XP Image
> > Generation.ps1:
> > 44 char:18
> > + invoke-expression <<<< $IGS_CDImage_Execute
> >
> > This points to the '.' in the cdimage.exe part of the string. Simply put,
> > all I want is the "..\Tools\cdimage.exe" component to execute the cdimage
> > executable, and the rest of the string be passed "raw" and unmodified
> > directly to the cdimage executable for it to interpret itself. Thanks again
> > for the help provided.
> >
> > -SDL
> > "Jeffrey Snover [MSFT]" wrote:
> >
> > > Jouko has it right.
> > > & says "use the next token as the NAME of the thing to execute"
> > >
> > > --
> > > Jeffrey Snover [MSFT]
> > > Windows PowerShell/Aspen Architect
> > > Microsoft Corporation
> > > This posting is provided "AS IS" with no warranties, no confers rights.
> > > Visit the Windows PowerShell Team blog at:
> > > http://blogs.msdn.com/PowerShell
> > > Visit the Windows PowerShell ScriptCenter at:
> > > http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx
> > >
> > >
> > >
 

My Computer

?

=?Utf-8?B?U0RM?=

#7
On another thought, if Option 1 is not possible or too difficult, and Option
2 could be used, a nice use for the PowerShell window would be to
consistently poll the cdimage process and display it's CPU and MEM Usage
every few seconds. I'd be pretty sure that would be possible through the
get-process cmdlet, might start looking at that in the meantime as well :)

-SDL

"SDL" wrote:

> Hello again dreeschkind :)
>
> Your method does indeed work, there are no longer any problems with execution!
>
> However, I have one last minor issue, purely aesthetic, but using this
> method the process is launched in a new window (cmd.exe) and instantly closes
> upon completion. I guess there are two possibilities here:
>
> 1. My first preference would be a method to simply run the process inside
> the PowerShell window(process), or failing that, background the cdimage.exe
> process but redirect all of it's output to the PowerShell process, which is
> almost just as good. I took a look at the relevant references in the MSDN
> library:
> http://msdn2.microsoft.com/en-us/library/system.diagnostics.processstartinfo_properties.aspx.
> Would the Redirect* objects be of use here? Sorry, but I'm not a programmer ;)
>
> 2. Failing that, I guess the next best option would be to simply have the
> process window automatically close on the completion of the process, this
> could be done through the "pause" command, but I'm not sure how or if that
> could be parsed with the process execution to ensure it runs immediately
> following the completion of the cdimage.exe process.
>
> Thanks for your help dreeschkind, it is very much appreciated.
>
> -SDL
>
> "dreeschkind" wrote:
>
> > I did not try this out, but may be this will work:
> >
> > ###############################################
> > $StartInfo = new-object System.Diagnostics.ProcessStartInfo
> > $StartInfo.FileName = '..\Tools\cdimage.exe'
> > $StartInfo.Arguments = '-lWXP_PRO_JUN06 -t08/26/2006/20/41/15
> > -b"..\src\bootsector.bin" -p0 -e -g -h -j1 -x -o -w1 -m "..\src" "C:\\Windows
> > XP Pro - June 2006 Update.iso"'
> > $StartInfo.WorkingDirectory = 'C:\' #fill in the correct directory here
> > $StartInfo.LoadUserProfile = $true
> > $StartInfo.UseShellExecute = $true
> > [System.Diagnostics.Process]::Start($StartInfo)
> > ###############################################
> >
> > Hope that helps.
> >
> > BTW: It might be easier to use only absolute path names and (if feasible)
> > fewer arguments first, so that you can eliminate possible sources of error.
> > This might help to localize the cause of failure.
> >
> > --
> > greetings
> > dreeschkind
> >
> > "SDL" wrote:
> >
> > > Greetings again,
> > >
> > > Thanks to both of you for the help, the 'invoke-expression' cmdlet is
> > > exactly what I was looking for. However, I'm still having issues with the
> > > command string being interpreted incorrectly. For example:
> > >
> > > '"..\Tools\cdimage.exe" -lWXP_PRO_JUN06 -t08/26/2006/20/41/15
> > > -b"..\src\bootsector.bin" -p0 -e -g -h -j1 -x -o -w1 -m "..\src" "C:\\Windows
> > > XP Pro - June 2006 Update.iso"'
> > > Invoke-Expression : You must provide a value expression on the right-hand
> > > side of the '-' operator. At X:\Scripts\Windows XP Image
> > > Generation.ps1:
> > > 44 char:18
> > > + invoke-expression <<<< $IGS_CDImage_Execute
> > >
> > > This points to the '.' in the cdimage.exe part of the string. Simply put,
> > > all I want is the "..\Tools\cdimage.exe" component to execute the cdimage
> > > executable, and the rest of the string be passed "raw" and unmodified
> > > directly to the cdimage executable for it to interpret itself. Thanks again
> > > for the help provided.
> > >
> > > -SDL
> > > "Jeffrey Snover [MSFT]" wrote:
> > >
> > > > Jouko has it right.
> > > > & says "use the next token as the NAME of the thing to execute"
> > > >
> > > > --
> > > > Jeffrey Snover [MSFT]
> > > > Windows PowerShell/Aspen Architect
> > > > Microsoft Corporation
> > > > This posting is provided "AS IS" with no warranties, no confers rights.
> > > > Visit the Windows PowerShell Team blog at:
> > > > http://blogs.msdn.com/PowerShell
> > > > Visit the Windows PowerShell ScriptCenter at:
> > > > http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx
> > > >
> > > >
> > > >
 

My Computer

?

=?Utf-8?B?ZHJlZXNjaGtpbmQ=?=

#8
"SDL" wrote:

> Hello again dreeschkind :)
>
> Your method does indeed work, there are no longer any problems with execution!
>
> However, I have one last minor issue, purely aesthetic, but using this
> method the process is launched in a new window (cmd.exe) and instantly closes
> upon completion. I guess there are two possibilities here:
>
> 1. My first preference would be a method to simply run the process inside
> the PowerShell window(process), or failing that, background the cdimage.exe
> process but redirect all of it's output to the PowerShell process, which is
> almost just as good. I took a look at the relevant references in the MSDN
> library:
> http://msdn2.microsoft.com/en-us/library/system.diagnostics.processstartinfo_properties.aspx.
> Would the Redirect* objects be of use here? Sorry, but I'm not a programmer ;)


Setting the property UseShellExecute to $false instead of $true before
starting your app should make it run inside the PowerShell window.

<...>
$StartInfo.UseShellExecute = $false
[System.Diagnostics.Process]::Start($StartInfo)


> 2. Failing that, I guess the next best option would be to simply have the
> process window automatically close on the completion of the process, this
> could be done through the "pause" command, but I'm not sure how or if that
> could be parsed with the process execution to ensure it runs immediately
> following the completion of the cdimage.exe process.


You can use this to wait for a specific process to finish:

#'cdimage' is the name as it appears in get-process (fill in the actual name
here)
$processToWatch = get-process cdimage
$processToWatch.WaitForExit()

Concerning your second post, you could monitor your cdimage.exe process
using something like this:

###############################################
$processToWatch = get-process cdimage
$oldPos = $host.UI.RawUI.CursorPosition
while ($processToWatch.HasExited -eq $false) {
$host.UI.RawUI.CursorPosition = $oldPos
$processToWatch | Format-Table Name, Id, CPU, VM
Start-Sleep 3
}
###############################################

--
greetings
dreeschkind

> Thanks for your help dreeschkind, it is very much appreciated.
>
> -SDL
>
> "dreeschkind" wrote:
>
> > I did not try this out, but may be this will work:
> >
> > ###############################################
> > $StartInfo = new-object System.Diagnostics.ProcessStartInfo
> > $StartInfo.FileName = '..\Tools\cdimage.exe'
> > $StartInfo.Arguments = '-lWXP_PRO_JUN06 -t08/26/2006/20/41/15
> > -b"..\src\bootsector.bin" -p0 -e -g -h -j1 -x -o -w1 -m "..\src" "C:\\Windows
> > XP Pro - June 2006 Update.iso"'
> > $StartInfo.WorkingDirectory = 'C:\' #fill in the correct directory here
> > $StartInfo.LoadUserProfile = $true
> > $StartInfo.UseShellExecute = $true
> > [System.Diagnostics.Process]::Start($StartInfo)
> > ###############################################
> >
> > Hope that helps.
> >
> > BTW: It might be easier to use only absolute path names and (if feasible)
> > fewer arguments first, so that you can eliminate possible sources of error.
> > This might help to localize the cause of failure.
> >
> > --
> > greetings
> > dreeschkind
> >
> > "SDL" wrote:
> >
> > > Greetings again,
> > >
> > > Thanks to both of you for the help, the 'invoke-expression' cmdlet is
> > > exactly what I was looking for. However, I'm still having issues with the
> > > command string being interpreted incorrectly. For example:
> > >
> > > '"..\Tools\cdimage.exe" -lWXP_PRO_JUN06 -t08/26/2006/20/41/15
> > > -b"..\src\bootsector.bin" -p0 -e -g -h -j1 -x -o -w1 -m "..\src" "C:\\Windows
> > > XP Pro - June 2006 Update.iso"'
> > > Invoke-Expression : You must provide a value expression on the right-hand
> > > side of the '-' operator. At X:\Scripts\Windows XP Image
> > > Generation.ps1:
> > > 44 char:18
> > > + invoke-expression <<<< $IGS_CDImage_Execute
> > >
> > > This points to the '.' in the cdimage.exe part of the string. Simply put,
> > > all I want is the "..\Tools\cdimage.exe" component to execute the cdimage
> > > executable, and the rest of the string be passed "raw" and unmodified
> > > directly to the cdimage executable for it to interpret itself. Thanks again
> > > for the help provided.
> > >
> > > -SDL
> > > "Jeffrey Snover [MSFT]" wrote:
> > >
> > > > Jouko has it right.
> > > > & says "use the next token as the NAME of the thing to execute"
> > > >
> > > > --
> > > > Jeffrey Snover [MSFT]
> > > > Windows PowerShell/Aspen Architect
> > > > Microsoft Corporation
> > > > This posting is provided "AS IS" with no warranties, no confers rights.
> > > > Visit the Windows PowerShell Team blog at:
> > > > http://blogs.msdn.com/PowerShell
> > > > Visit the Windows PowerShell ScriptCenter at:
> > > > http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx
> > > >
> > > >
> > > >
 

My Computer

?

=?Utf-8?B?U0RM?=

#9
Greetings and thanks for all of your help dreeschkind :)

Your advice on the two methods of execution worked perfectly on both counts,
and the script is 99% complete. However, I am having what I think is a fairly
odd problem with your Process polling sample script. When run inside the main
script with everything else, the following error appears and the script
terminates (although the cdimage process continues to run in a seperate
window):
out-lineoutput : Object of type
"Microsoft.PowerShell.Commands.Internal.Format.FormatStartData" is not legal
or not in the correct sequence. This is likely caused by a user specified
"format-table" command which is conflicting with the default formatting.

However, if I copy the _exact_ 6 lines of code into a seperate script and
manually execute said script while the cdimage process is running, it works
fine :/

Any thoughts?

-SDL
"dreeschkind" wrote:

> "SDL" wrote:
>
> > Hello again dreeschkind :)
> >
> > Your method does indeed work, there are no longer any problems with execution!
> >
> > However, I have one last minor issue, purely aesthetic, but using this
> > method the process is launched in a new window (cmd.exe) and instantly closes
> > upon completion. I guess there are two possibilities here:
> >
> > 1. My first preference would be a method to simply run the process inside
> > the PowerShell window(process), or failing that, background the cdimage.exe
> > process but redirect all of it's output to the PowerShell process, which is
> > almost just as good. I took a look at the relevant references in the MSDN
> > library:
> > http://msdn2.microsoft.com/en-us/library/system.diagnostics.processstartinfo_properties.aspx.
> > Would the Redirect* objects be of use here? Sorry, but I'm not a programmer ;)

>
> Setting the property UseShellExecute to $false instead of $true before
> starting your app should make it run inside the PowerShell window.
>
> <...>
> $StartInfo.UseShellExecute = $false
> [System.Diagnostics.Process]::Start($StartInfo)
>
>
> > 2. Failing that, I guess the next best option would be to simply have the
> > process window automatically close on the completion of the process, this
> > could be done through the "pause" command, but I'm not sure how or if that
> > could be parsed with the process execution to ensure it runs immediately
> > following the completion of the cdimage.exe process.

>
> You can use this to wait for a specific process to finish:
>
> #'cdimage' is the name as it appears in get-process (fill in the actual name
> here)
> $processToWatch = get-process cdimage
> $processToWatch.WaitForExit()
>
> Concerning your second post, you could monitor your cdimage.exe process
> using something like this:
>
> ###############################################
> $processToWatch = get-process cdimage
> $oldPos = $host.UI.RawUI.CursorPosition
> while ($processToWatch.HasExited -eq $false) {
> $host.UI.RawUI.CursorPosition = $oldPos
> $processToWatch | Format-Table Name, Id, CPU, VM
> Start-Sleep 3
> }
> ###############################################
>
> --
> greetings
> dreeschkind
>
> > Thanks for your help dreeschkind, it is very much appreciated.
> >
> > -SDL
> >
> > "dreeschkind" wrote:
> >
> > > I did not try this out, but may be this will work:
> > >
> > > ###############################################
> > > $StartInfo = new-object System.Diagnostics.ProcessStartInfo
> > > $StartInfo.FileName = '..\Tools\cdimage.exe'
> > > $StartInfo.Arguments = '-lWXP_PRO_JUN06 -t08/26/2006/20/41/15
> > > -b"..\src\bootsector.bin" -p0 -e -g -h -j1 -x -o -w1 -m "..\src" "C:\\Windows
> > > XP Pro - June 2006 Update.iso"'
> > > $StartInfo.WorkingDirectory = 'C:\' #fill in the correct directory here
> > > $StartInfo.LoadUserProfile = $true
> > > $StartInfo.UseShellExecute = $true
> > > [System.Diagnostics.Process]::Start($StartInfo)
> > > ###############################################
> > >
> > > Hope that helps.
> > >
> > > BTW: It might be easier to use only absolute path names and (if feasible)
> > > fewer arguments first, so that you can eliminate possible sources of error.
> > > This might help to localize the cause of failure.
> > >
> > > --
> > > greetings
> > > dreeschkind
> > >
> > > "SDL" wrote:
> > >
> > > > Greetings again,
> > > >
> > > > Thanks to both of you for the help, the 'invoke-expression' cmdlet is
> > > > exactly what I was looking for. However, I'm still having issues with the
> > > > command string being interpreted incorrectly. For example:
> > > >
> > > > '"..\Tools\cdimage.exe" -lWXP_PRO_JUN06 -t08/26/2006/20/41/15
> > > > -b"..\src\bootsector.bin" -p0 -e -g -h -j1 -x -o -w1 -m "..\src" "C:\\Windows
> > > > XP Pro - June 2006 Update.iso"'
> > > > Invoke-Expression : You must provide a value expression on the right-hand
> > > > side of the '-' operator. At X:\Scripts\Windows XP Image
> > > > Generation.ps1:
> > > > 44 char:18
> > > > + invoke-expression <<<< $IGS_CDImage_Execute
> > > >
> > > > This points to the '.' in the cdimage.exe part of the string. Simply put,
> > > > all I want is the "..\Tools\cdimage.exe" component to execute the cdimage
> > > > executable, and the rest of the string be passed "raw" and unmodified
> > > > directly to the cdimage executable for it to interpret itself. Thanks again
> > > > for the help provided.
> > > >
> > > > -SDL
> > > > "Jeffrey Snover [MSFT]" wrote:
> > > >
> > > > > Jouko has it right.
> > > > > & says "use the next token as the NAME of the thing to execute"
> > > > >
> > > > > --
> > > > > Jeffrey Snover [MSFT]
> > > > > Windows PowerShell/Aspen Architect
> > > > > Microsoft Corporation
> > > > > This posting is provided "AS IS" with no warranties, no confers rights.
> > > > > Visit the Windows PowerShell Team blog at:
> > > > > http://blogs.msdn.com/PowerShell
> > > > > Visit the Windows PowerShell ScriptCenter at:
> > > > > http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx
> > > > >
> > > > >
> > > > >
 

My Computer

?

=?Utf-8?B?ZHJlZXNjaGtpbmQ=?=

#10
"SDL" wrote:

> Greetings and thanks for all of your help dreeschkind :)
>
> Your advice on the two methods of execution worked perfectly on both counts,
> and the script is 99% complete. However, I am having what I think is a fairly
> odd problem with your Process polling sample script. When run inside the main
> script with everything else, the following error appears and the script
> terminates (although the cdimage process continues to run in a seperate
> window):
> out-lineoutput : Object of type
> "Microsoft.PowerShell.Commands.Internal.Format.FormatStartData" is not legal
> or not in the correct sequence. This is likely caused by a user specified
> "format-table" command which is conflicting with the default formatting.
>
> However, if I copy the _exact_ 6 lines of code into a seperate script and
> manually execute said script while the cdimage process is running, it works
> fine :/
>
> Any thoughts?


Sorry, I guess this was my fault, I only tested my code in the shell as
well. ;-)
I tried to simplify the display of the properties by using the formatting
capabilities of format-table. Unfortunately, using (different) format-*
cmdlets inside ps1 script files causes the error you described, because
switching the formatting within the pipeline is not possible (at the moment).
Someone from the team might actually explain this a little bit better than me.
However, I think it should be possible to workaround this issue by using
your own code for displaying the values you are interested in.
Try this code and tell me if it works now:

$processToWatch = get-process cdimage
$oldPos = $host.UI.RawUI.CursorPosition
while ($processToWatch.HasExited -eq $false) {
$host.UI.RawUI.CursorPosition = $oldPos

#use write-host 3 times to display a table of the properties
Write-Host "Name`t|`tId`t|`tCPU`t`t|`tVM"
Write-Host $("-"*70)
Write-Host
"$($processToWatch.Name)`t|`t$($processToWatch.Id)`t|`t$($processToWatch.CPU)`t|`t$($processToWatch.VM)"

Start-Sleep 3
}

--
greetings
dreeschkind

> -SDL
> "dreeschkind" wrote:
>
> > "SDL" wrote:
> >
> > > Hello again dreeschkind :)
> > >
> > > Your method does indeed work, there are no longer any problems with execution!
> > >
> > > However, I have one last minor issue, purely aesthetic, but using this
> > > method the process is launched in a new window (cmd.exe) and instantly closes
> > > upon completion. I guess there are two possibilities here:
> > >
> > > 1. My first preference would be a method to simply run the process inside
> > > the PowerShell window(process), or failing that, background the cdimage.exe
> > > process but redirect all of it's output to the PowerShell process, which is
> > > almost just as good. I took a look at the relevant references in the MSDN
> > > library:
> > > http://msdn2.microsoft.com/en-us/library/system.diagnostics.processstartinfo_properties.aspx.
> > > Would the Redirect* objects be of use here? Sorry, but I'm not a programmer ;)

> >
> > Setting the property UseShellExecute to $false instead of $true before
> > starting your app should make it run inside the PowerShell window.
> >
> > <...>
> > $StartInfo.UseShellExecute = $false
> > [System.Diagnostics.Process]::Start($StartInfo)
> >
> >
> > > 2. Failing that, I guess the next best option would be to simply have the
> > > process window automatically close on the completion of the process, this
> > > could be done through the "pause" command, but I'm not sure how or if that
> > > could be parsed with the process execution to ensure it runs immediately
> > > following the completion of the cdimage.exe process.

> >
> > You can use this to wait for a specific process to finish:
> >
> > #'cdimage' is the name as it appears in get-process (fill in the actual name
> > here)
> > $processToWatch = get-process cdimage
> > $processToWatch.WaitForExit()
> >
> > Concerning your second post, you could monitor your cdimage.exe process
> > using something like this:
> >
> > ###############################################
> > $processToWatch = get-process cdimage
> > $oldPos = $host.UI.RawUI.CursorPosition
> > while ($processToWatch.HasExited -eq $false) {
> > $host.UI.RawUI.CursorPosition = $oldPos
> > $processToWatch | Format-Table Name, Id, CPU, VM
> > Start-Sleep 3
> > }
> > ###############################################
> >
> > --
> > greetings
> > dreeschkind
> >
> > > Thanks for your help dreeschkind, it is very much appreciated.
> > >
> > > -SDL
> > >
> > > "dreeschkind" wrote:
> > >
> > > > I did not try this out, but may be this will work:
> > > >
> > > > ###############################################
> > > > $StartInfo = new-object System.Diagnostics.ProcessStartInfo
> > > > $StartInfo.FileName = '..\Tools\cdimage.exe'
> > > > $StartInfo.Arguments = '-lWXP_PRO_JUN06 -t08/26/2006/20/41/15
> > > > -b"..\src\bootsector.bin" -p0 -e -g -h -j1 -x -o -w1 -m "..\src" "C:\\Windows
> > > > XP Pro - June 2006 Update.iso"'
> > > > $StartInfo.WorkingDirectory = 'C:\' #fill in the correct directory here
> > > > $StartInfo.LoadUserProfile = $true
> > > > $StartInfo.UseShellExecute = $true
> > > > [System.Diagnostics.Process]::Start($StartInfo)
> > > > ###############################################
> > > >
> > > > Hope that helps.
> > > >
> > > > BTW: It might be easier to use only absolute path names and (if feasible)
> > > > fewer arguments first, so that you can eliminate possible sources of error.
> > > > This might help to localize the cause of failure.
> > > >
> > > > --
> > > > greetings
> > > > dreeschkind
> > > >
> > > > "SDL" wrote:
> > > >
> > > > > Greetings again,
> > > > >
> > > > > Thanks to both of you for the help, the 'invoke-expression' cmdlet is
> > > > > exactly what I was looking for. However, I'm still having issues with the
> > > > > command string being interpreted incorrectly. For example:
> > > > >
> > > > > '"..\Tools\cdimage.exe" -lWXP_PRO_JUN06 -t08/26/2006/20/41/15
> > > > > -b"..\src\bootsector.bin" -p0 -e -g -h -j1 -x -o -w1 -m "..\src" "C:\\Windows
> > > > > XP Pro - June 2006 Update.iso"'
> > > > > Invoke-Expression : You must provide a value expression on the right-hand
> > > > > side of the '-' operator. At X:\Scripts\Windows XP Image
> > > > > Generation.ps1:
> > > > > 44 char:18
> > > > > + invoke-expression <<<< $IGS_CDImage_Execute
> > > > >
> > > > > This points to the '.' in the cdimage.exe part of the string. Simply put,
> > > > > all I want is the "..\Tools\cdimage.exe" component to execute the cdimage
> > > > > executable, and the rest of the string be passed "raw" and unmodified
> > > > > directly to the cdimage executable for it to interpret itself. Thanks again
> > > > > for the help provided.
> > > > >
> > > > > -SDL
> > > > > "Jeffrey Snover [MSFT]" wrote:
> > > > >
> > > > > > Jouko has it right.
> > > > > > & says "use the next token as the NAME of the thing to execute"
> > > > > >
> > > > > > --
> > > > > > Jeffrey Snover [MSFT]
> > > > > > Windows PowerShell/Aspen Architect
> > > > > > Microsoft Corporation
> > > > > > This posting is provided "AS IS" with no warranties, no confers rights.
> > > > > > Visit the Windows PowerShell Team blog at:
> > > > > > http://blogs.msdn.com/PowerShell
> > > > > > Visit the Windows PowerShell ScriptCenter at:
> > > > > > http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx
> > > > > >
> > > > > >
> > > > > >
 

My Computer

?

=?Utf-8?B?U0RM?=

#11
It does indeed work.

One final question:
When the cdimage process is executed by
"[System.Diagnostics.Process]::Start($IGS_CDImage)", a get-process cdimage
output is sent to the pipeline. Immediately after, the Process Monitor code
is executed, resulting in a second get-process output that is updated in
three second intervals below the original get-process output which is out-of
date.

Is it possible to make the process execute silently, i.e., there is no
process information output on start?

A sample of the output I am referring to is below:
# This one is the initial output from the process start (not-updated)
Id : 5864
Handles : 29
CPU : 0.109375
Name : cdimage
# Immediately following is this output from the process monitor code
(updated every three seconds)
Id : 5864
Handles : 29
CPU : 0.781255
Name : cdimage

Thanks again for all your help,

-SDL

"dreeschkind" wrote:

> "SDL" wrote:
>
> > Greetings and thanks for all of your help dreeschkind :)
> >
> > Your advice on the two methods of execution worked perfectly on both counts,
> > and the script is 99% complete. However, I am having what I think is a fairly
> > odd problem with your Process polling sample script. When run inside the main
> > script with everything else, the following error appears and the script
> > terminates (although the cdimage process continues to run in a seperate
> > window):
> > out-lineoutput : Object of type
> > "Microsoft.PowerShell.Commands.Internal.Format.FormatStartData" is not legal
> > or not in the correct sequence. This is likely caused by a user specified
> > "format-table" command which is conflicting with the default formatting.
> >
> > However, if I copy the _exact_ 6 lines of code into a seperate script and
> > manually execute said script while the cdimage process is running, it works
> > fine :/
> >
> > Any thoughts?

>
> Sorry, I guess this was my fault, I only tested my code in the shell as
> well. ;-)
> I tried to simplify the display of the properties by using the formatting
> capabilities of format-table. Unfortunately, using (different) format-*
> cmdlets inside ps1 script files causes the error you described, because
> switching the formatting within the pipeline is not possible (at the moment).
> Someone from the team might actually explain this a little bit better than me.
> However, I think it should be possible to workaround this issue by using
> your own code for displaying the values you are interested in.
> Try this code and tell me if it works now:
>
> $processToWatch = get-process cdimage
> $oldPos = $host.UI.RawUI.CursorPosition
> while ($processToWatch.HasExited -eq $false) {
> $host.UI.RawUI.CursorPosition = $oldPos
>
> #use write-host 3 times to display a table of the properties
> Write-Host "Name`t|`tId`t|`tCPU`t`t|`tVM"
> Write-Host $("-"*70)
> Write-Host
> "$($processToWatch.Name)`t|`t$($processToWatch.Id)`t|`t$($processToWatch.CPU)`t|`t$($processToWatch.VM)"
>
> Start-Sleep 3
> }
>
> --
> greetings
> dreeschkind
>
> > -SDL
> > "dreeschkind" wrote:
> >
> > > "SDL" wrote:
> > >
> > > > Hello again dreeschkind :)
> > > >
> > > > Your method does indeed work, there are no longer any problems with execution!
> > > >
> > > > However, I have one last minor issue, purely aesthetic, but using this
> > > > method the process is launched in a new window (cmd.exe) and instantly closes
> > > > upon completion. I guess there are two possibilities here:
> > > >
> > > > 1. My first preference would be a method to simply run the process inside
> > > > the PowerShell window(process), or failing that, background the cdimage.exe
> > > > process but redirect all of it's output to the PowerShell process, which is
> > > > almost just as good. I took a look at the relevant references in the MSDN
> > > > library:
> > > > http://msdn2.microsoft.com/en-us/library/system.diagnostics.processstartinfo_properties.aspx.
> > > > Would the Redirect* objects be of use here? Sorry, but I'm not a programmer ;)
> > >
> > > Setting the property UseShellExecute to $false instead of $true before
> > > starting your app should make it run inside the PowerShell window.
> > >
> > > <...>
> > > $StartInfo.UseShellExecute = $false
> > > [System.Diagnostics.Process]::Start($StartInfo)
> > >
> > >
> > > > 2. Failing that, I guess the next best option would be to simply have the
> > > > process window automatically close on the completion of the process, this
> > > > could be done through the "pause" command, but I'm not sure how or if that
> > > > could be parsed with the process execution to ensure it runs immediately
> > > > following the completion of the cdimage.exe process.
> > >
> > > You can use this to wait for a specific process to finish:
> > >
> > > #'cdimage' is the name as it appears in get-process (fill in the actual name
> > > here)
> > > $processToWatch = get-process cdimage
> > > $processToWatch.WaitForExit()
> > >
> > > Concerning your second post, you could monitor your cdimage.exe process
> > > using something like this:
> > >
> > > ###############################################
> > > $processToWatch = get-process cdimage
> > > $oldPos = $host.UI.RawUI.CursorPosition
> > > while ($processToWatch.HasExited -eq $false) {
> > > $host.UI.RawUI.CursorPosition = $oldPos
> > > $processToWatch | Format-Table Name, Id, CPU, VM
> > > Start-Sleep 3
> > > }
> > > ###############################################
> > >
> > > --
> > > greetings
> > > dreeschkind
> > >
> > > > Thanks for your help dreeschkind, it is very much appreciated.
> > > >
> > > > -SDL
> > > >
> > > > "dreeschkind" wrote:
> > > >
> > > > > I did not try this out, but may be this will work:
> > > > >
> > > > > ###############################################
> > > > > $StartInfo = new-object System.Diagnostics.ProcessStartInfo
> > > > > $StartInfo.FileName = '..\Tools\cdimage.exe'
> > > > > $StartInfo.Arguments = '-lWXP_PRO_JUN06 -t08/26/2006/20/41/15
> > > > > -b"..\src\bootsector.bin" -p0 -e -g -h -j1 -x -o -w1 -m "..\src" "C:\\Windows
> > > > > XP Pro - June 2006 Update.iso"'
> > > > > $StartInfo.WorkingDirectory = 'C:\' #fill in the correct directory here
> > > > > $StartInfo.LoadUserProfile = $true
> > > > > $StartInfo.UseShellExecute = $true
> > > > > [System.Diagnostics.Process]::Start($StartInfo)
> > > > > ###############################################
> > > > >
> > > > > Hope that helps.
> > > > >
> > > > > BTW: It might be easier to use only absolute path names and (if feasible)
> > > > > fewer arguments first, so that you can eliminate possible sources of error.
> > > > > This might help to localize the cause of failure.
> > > > >
> > > > > --
> > > > > greetings
> > > > > dreeschkind
> > > > >
> > > > > "SDL" wrote:
> > > > >
> > > > > > Greetings again,
> > > > > >
> > > > > > Thanks to both of you for the help, the 'invoke-expression' cmdlet is
> > > > > > exactly what I was looking for. However, I'm still having issues with the
> > > > > > command string being interpreted incorrectly. For example:
> > > > > >
> > > > > > '"..\Tools\cdimage.exe" -lWXP_PRO_JUN06 -t08/26/2006/20/41/15
> > > > > > -b"..\src\bootsector.bin" -p0 -e -g -h -j1 -x -o -w1 -m "..\src" "C:\\Windows
> > > > > > XP Pro - June 2006 Update.iso"'
> > > > > > Invoke-Expression : You must provide a value expression on the right-hand
> > > > > > side of the '-' operator. At X:\Scripts\Windows XP Image
> > > > > > Generation.ps1:
> > > > > > 44 char:18
> > > > > > + invoke-expression <<<< $IGS_CDImage_Execute
> > > > > >
> > > > > > This points to the '.' in the cdimage.exe part of the string. Simply put,
> > > > > > all I want is the "..\Tools\cdimage.exe" component to execute the cdimage
> > > > > > executable, and the rest of the string be passed "raw" and unmodified
> > > > > > directly to the cdimage executable for it to interpret itself. Thanks again
> > > > > > for the help provided.
> > > > > >
> > > > > > -SDL
> > > > > > "Jeffrey Snover [MSFT]" wrote:
> > > > > >
> > > > > > > Jouko has it right.
> > > > > > > & says "use the next token as the NAME of the thing to execute"
> > > > > > >
> > > > > > > --
> > > > > > > Jeffrey Snover [MSFT]
> > > > > > > Windows PowerShell/Aspen Architect
> > > > > > > Microsoft Corporation
> > > > > > > This posting is provided "AS IS" with no warranties, no confers rights.
> > > > > > > Visit the Windows PowerShell Team blog at:
> > > > > > > http://blogs.msdn.com/PowerShell
> > > > > > > Visit the Windows PowerShell ScriptCenter at:
> > > > > > > http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx
> > > > > > >
> > > > > > >
> > > > > > >
 

My Computer

?

=?Utf-8?B?ZHJlZXNjaGtpbmQ=?=

#12
You can save the reference to your newly created process this way:

$processToWatch = [System.Diagnostics.Process]::Start($StartInfo)

Using this syntax, the output won't get printed to the console.
Since now you have already saved your process reference, you don't have to
get it again using something like that:

$processToWatch = get-process cdimage

Because I don't know how your code looks like now, I can't say for sure what
causes all the output you get. Generally speaking, output gets written to the
console by using explicit cmdlets like:

write-host "foo" # writes to the console

or:

write-output "foo" #writes output to the pipeline
#at the end of the pipeline all what is
left in it
#gets written to the console (by default)

Output also gets written to the pipe by just calling the name of a variable
like this:

$processToWatch

and as you have seen, some methods and cmdlets (like: new-object) return
objects as well, that also get written to the pipeline if not assigned to a
variable:

[System.Diagnostics.Process]::Start($StartInfo)

There are many ways to stop PowerShell from putting stuff inside the pipeline:

get-process | out-null #piping everything to out-null
[void] (get-process) #casting the result of get-process to void
$null = get-process #assigning the result of get-process to $null
$myvar= get-process #assigning the result of get-process to any variable

I hope you can adapt this for your script, otherwise I have to have a look
at it to see what exactly goes wrong.

--
greetings
dreeschkind

"SDL" wrote:

> It does indeed work.
>
> One final question:
> When the cdimage process is executed by
> "[System.Diagnostics.Process]::Start($IGS_CDImage)", a get-process cdimage
> output is sent to the pipeline. Immediately after, the Process Monitor code
> is executed, resulting in a second get-process output that is updated in
> three second intervals below the original get-process output which is out-of
> date.
>
> Is it possible to make the process execute silently, i.e., there is no
> process information output on start?
>
> A sample of the output I am referring to is below:
> # This one is the initial output from the process start (not-updated)
> Id : 5864
> Handles : 29
> CPU : 0.109375
> Name : cdimage
> # Immediately following is this output from the process monitor code
> (updated every three seconds)
> Id : 5864
> Handles : 29
> CPU : 0.781255
> Name : cdimage
>
> Thanks again for all your help,
>
> -SDL
>
> "dreeschkind" wrote:
>
> > "SDL" wrote:
> >
> > > Greetings and thanks for all of your help dreeschkind :)
> > >
> > > Your advice on the two methods of execution worked perfectly on both counts,
> > > and the script is 99% complete. However, I am having what I think is a fairly
> > > odd problem with your Process polling sample script. When run inside the main
> > > script with everything else, the following error appears and the script
> > > terminates (although the cdimage process continues to run in a seperate
> > > window):
> > > out-lineoutput : Object of type
> > > "Microsoft.PowerShell.Commands.Internal.Format.FormatStartData" is not legal
> > > or not in the correct sequence. This is likely caused by a user specified
> > > "format-table" command which is conflicting with the default formatting.
> > >
> > > However, if I copy the _exact_ 6 lines of code into a seperate script and
> > > manually execute said script while the cdimage process is running, it works
> > > fine :/
> > >
> > > Any thoughts?

> >
> > Sorry, I guess this was my fault, I only tested my code in the shell as
> > well. ;-)
> > I tried to simplify the display of the properties by using the formatting
> > capabilities of format-table. Unfortunately, using (different) format-*
> > cmdlets inside ps1 script files causes the error you described, because
> > switching the formatting within the pipeline is not possible (at the moment).
> > Someone from the team might actually explain this a little bit better than me.
> > However, I think it should be possible to workaround this issue by using
> > your own code for displaying the values you are interested in.
> > Try this code and tell me if it works now:
> >
> > $processToWatch = get-process cdimage
> > $oldPos = $host.UI.RawUI.CursorPosition
> > while ($processToWatch.HasExited -eq $false) {
> > $host.UI.RawUI.CursorPosition = $oldPos
> >
> > #use write-host 3 times to display a table of the properties
> > Write-Host "Name`t|`tId`t|`tCPU`t`t|`tVM"
> > Write-Host $("-"*70)
> > Write-Host
> > "$($processToWatch.Name)`t|`t$($processToWatch.Id)`t|`t$($processToWatch.CPU)`t|`t$($processToWatch.VM)"
> >
> > Start-Sleep 3
> > }
> >
> > --
> > greetings
> > dreeschkind
> >
> > > -SDL
> > > "dreeschkind" wrote:
> > >
> > > > "SDL" wrote:
> > > >
> > > > > Hello again dreeschkind :)
> > > > >
> > > > > Your method does indeed work, there are no longer any problems with execution!
> > > > >
> > > > > However, I have one last minor issue, purely aesthetic, but using this
> > > > > method the process is launched in a new window (cmd.exe) and instantly closes
> > > > > upon completion. I guess there are two possibilities here:
> > > > >
> > > > > 1. My first preference would be a method to simply run the process inside
> > > > > the PowerShell window(process), or failing that, background the cdimage.exe
> > > > > process but redirect all of it's output to the PowerShell process, which is
> > > > > almost just as good. I took a look at the relevant references in the MSDN
> > > > > library:
> > > > > http://msdn2.microsoft.com/en-us/library/system.diagnostics.processstartinfo_properties.aspx.
> > > > > Would the Redirect* objects be of use here? Sorry, but I'm not a programmer ;)
> > > >
> > > > Setting the property UseShellExecute to $false instead of $true before
> > > > starting your app should make it run inside the PowerShell window.
> > > >
> > > > <...>
> > > > $StartInfo.UseShellExecute = $false
> > > > [System.Diagnostics.Process]::Start($StartInfo)
> > > >
> > > >
> > > > > 2. Failing that, I guess the next best option would be to simply have the
> > > > > process window automatically close on the completion of the process, this
> > > > > could be done through the "pause" command, but I'm not sure how or if that
> > > > > could be parsed with the process execution to ensure it runs immediately
> > > > > following the completion of the cdimage.exe process.
> > > >
> > > > You can use this to wait for a specific process to finish:
> > > >
> > > > #'cdimage' is the name as it appears in get-process (fill in the actual name
> > > > here)
> > > > $processToWatch = get-process cdimage
> > > > $processToWatch.WaitForExit()
> > > >
> > > > Concerning your second post, you could monitor your cdimage.exe process
> > > > using something like this:
> > > >
> > > > ###############################################
> > > > $processToWatch = get-process cdimage
> > > > $oldPos = $host.UI.RawUI.CursorPosition
> > > > while ($processToWatch.HasExited -eq $false) {
> > > > $host.UI.RawUI.CursorPosition = $oldPos
> > > > $processToWatch | Format-Table Name, Id, CPU, VM
> > > > Start-Sleep 3
> > > > }
> > > > ###############################################
> > > >
> > > > --
> > > > greetings
> > > > dreeschkind
> > > >
> > > > > Thanks for your help dreeschkind, it is very much appreciated.
> > > > >
> > > > > -SDL
> > > > >
> > > > > "dreeschkind" wrote:
> > > > >
> > > > > > I did not try this out, but may be this will work:
> > > > > >
> > > > > > ###############################################
> > > > > > $StartInfo = new-object System.Diagnostics.ProcessStartInfo
> > > > > > $StartInfo.FileName = '..\Tools\cdimage.exe'
> > > > > > $StartInfo.Arguments = '-lWXP_PRO_JUN06 -t08/26/2006/20/41/15
> > > > > > -b"..\src\bootsector.bin" -p0 -e -g -h -j1 -x -o -w1 -m "..\src" "C:\\Windows
> > > > > > XP Pro - June 2006 Update.iso"'
> > > > > > $StartInfo.WorkingDirectory = 'C:\' #fill in the correct directory here
> > > > > > $StartInfo.LoadUserProfile = $true
> > > > > > $StartInfo.UseShellExecute = $true
> > > > > > [System.Diagnostics.Process]::Start($StartInfo)
> > > > > > ###############################################
> > > > > >
> > > > > > Hope that helps.
> > > > > >
> > > > > > BTW: It might be easier to use only absolute path names and (if feasible)
> > > > > > fewer arguments first, so that you can eliminate possible sources of error.
> > > > > > This might help to localize the cause of failure.
> > > > > >
> > > > > > --
> > > > > > greetings
> > > > > > dreeschkind
> > > > > >
> > > > > > "SDL" wrote:
> > > > > >
> > > > > > > Greetings again,
> > > > > > >
> > > > > > > Thanks to both of you for the help, the 'invoke-expression' cmdlet is
> > > > > > > exactly what I was looking for. However, I'm still having issues with the
> > > > > > > command string being interpreted incorrectly. For example:
> > > > > > >
> > > > > > > '"..\Tools\cdimage.exe" -lWXP_PRO_JUN06 -t08/26/2006/20/41/15
> > > > > > > -b"..\src\bootsector.bin" -p0 -e -g -h -j1 -x -o -w1 -m "..\src" "C:\\Windows
> > > > > > > XP Pro - June 2006 Update.iso"'
> > > > > > > Invoke-Expression : You must provide a value expression on the right-hand
> > > > > > > side of the '-' operator. At X:\Scripts\Windows XP Image
> > > > > > > Generation.ps1:
> > > > > > > 44 char:18
> > > > > > > + invoke-expression <<<< $IGS_CDImage_Execute
> > > > > > >
> > > > > > > This points to the '.' in the cdimage.exe part of the string. Simply put,
> > > > > > > all I want is the "..\Tools\cdimage.exe" component to execute the cdimage
> > > > > > > executable, and the rest of the string be passed "raw" and unmodified
> > > > > > > directly to the cdimage executable for it to interpret itself. Thanks again
> > > > > > > for the help provided.
> > > > > > >
> > > > > > > -SDL
> > > > > > > "Jeffrey Snover [MSFT]" wrote:
> > > > > > >
> > > > > > > > Jouko has it right.
> > > > > > > > & says "use the next token as the NAME of the thing to execute"
> > > > > > > >
> > > > > > > > --
> > > > > > > > Jeffrey Snover [MSFT]
> > > > > > > > Windows PowerShell/Aspen Architect
> > > > > > > > Microsoft Corporation
> > > > > > > > This posting is provided "AS IS" with no warranties, no confers rights.
> > > > > > > > Visit the Windows PowerShell Team blog at:
> > > > > > > > http://blogs.msdn.com/PowerShell
> > > > > > > > Visit the Windows PowerShell ScriptCenter at:
> > > > > > > > http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx
> > > > > > > >
> > > > > > > >
> > > > > > > >
 

My Computer

Users Who Are Viewing This Thread (Users: 1, Guests: 0)