Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Thursday, February 8, 2018 8:34 PM
I am using Windows Server 20012 (Powershell 5.0)
I would like to start a Symantec Ghost process which will make a VMDK from a Ghost file. This snippet works using the "&" or call command. However, a side effect of this command is that an empty Windows Powershell console get's launched which if I close it, kills the entire script. I get this window if I run it in the ISE or if I launch the script from a VBS script.
# Particularly difficult to launch Ghost with it's unique parameter structure in PowerShell
$arg1 = "-clone,mode=restore,src=C:\ghost\file.gho,dst=C:\vmdks\file.vmdk"
$arg2 = "-vmdkAdapter=lsilogic"
$arg3 = "-vmdkSize=$diskSize"
$arg4 = "-ntexact"
$arg5 = "-sure"
$ allArgs = @($arg1, $arg2, $arg3, $arg4, $arg5)
& C:\ghost32.exe $allArgs
I've tried the Start-Process cmdlet because it has the -NoWindow option, but can't get the command to launch. I've tried a bunch of things including the following:
# build arglist as an array
$allArgs = $arg1, $arg2, $arg3,$arg4,$arg5
Start-Process "C:\ghost32.exe -argumentList $allArgs
#build arglist as a single string
$allArgs = "$arg1 $arg2 $arg3 $arg4 $arg5"
Start-Process "C:\ghost32.exe -argumentList $allArgs
#build arglist like &/call cmd
$allArgs = @($arg1, $arg2, $arg3,$arg4,$arg5)
Start-Process "C:\ghost32.exe -argumentList $allArgs
I would appreciate any suggestions on how to get this working.
All replies (8)
Sunday, February 11, 2018 9:19 PM ✅Answered
I kind of got this working. I was never able to remove the console window, but I was able to minimize the impact.
Once I passed in my arguments to Start-Process with the -ArgumentList parameter, I was able to launch the process with all the crazy ghost arguments.
The console window is still created, but it is minimized and a user is less likely to notice it. However, if it does get accidently closed, it will just terminate the Ghost process and not the entire script.
$arg1 = "-clone,mode=restore,src=C:\ghost\file.gho,dst=C:\vmdks\file.vmdk"
$arg2 = "-vmdkAdapter=lsilogic"
$arg3 = "-vmdkSize=$diskSize"
$arg4 = "-ntexact"
$arg5 = "-sure"
$allArgs = @($arg1, $arg2, $arg3, $arg4, $arg5)
Start-Process "C:\ghost32.exe" -ArgumentList $allArgs -Wait -NoNewWindow
Thursday, February 8, 2018 8:39 PM | 1 vote
Start-Process C:\ghost32.exe -argumentList $allArgs -NoNewWindow
If any process has GUI output it will always start in a new window.
\(ツ)_/
Thursday, February 8, 2018 8:56 PM
Right, but my start-process isn't working with these arguments. It throws up a console window which immediately closes without running the executable.
Thursday, February 8, 2018 9:16 PM
$p = Start-Process C:\ghost32.exe -argumentList $allArgs -PassThru
$p.ExitCode
The issue is that your arguments are bad. You will have to post in a ghost forum to learn how to pass the args.
\(ツ)_/
Thursday, February 8, 2018 9:43 PM
Thanks, I was kind of hoping that since it worked with the & command I could tweak start-process to work, too.
Friday, February 9, 2018 5:12 AM
Hi,
I'm checking how the issue is going, was your issue resolved?
And if the replies as above are helpful, we would appreciate you to mark them as answers, and if you resolve it using your own solution, please share your experience and solution here. It will be greatly helpful to others who have the same question.
Appreciate for your feedback.
Best Regards,
Albert
Please remember to mark the replies as an answers if they help.
If you have feedback for TechNet Subscriber Support, contact [email protected]
Friday, February 9, 2018 12:28 PM
No, I was hoping someone could either help me fix the arguments to the Start-Process cmdlet or find a way to execute the & command without a separate console window. I will work on it over the weekend and close it out on Monday.
Friday, February 9, 2018 12:36 PM
The issue is not with PowerShell it is with ghost.
\(ツ)_/