Thursday, February 9, 2012

Another PS1Batch approach

For some reason the Win7 Home Premium at home and my Win7 Pro at work, don't handle batch file errors the same.

Last nights approach the batch would display an error that "<# was an invalid command line, but would go to the next line and keep kicking.  At work, the whole batch file terminates.

I tried a few variations on Commenting the line, but all of them either killed the PS1 on the load error checks, or had the same effect.

But my command shell at work doesn't care about the following.



$Batchfile = @"
Cls
copy %~dpn0.BAT %~dpn0.ps1
powershell.exe -Noprofile -ExecutionPolicy Unrestricted -file %~dpn0.ps1
::Pause
DEL %~dpn0.ps1
GOTO :EOF
"@
("1+1="+(1+1))