I need to run a PowerShell script using PowerShell or some other means in another desktop without switching back and forth across desktops. I could not find any cmdlet or other way to accomplish this. Could someone help?
$file1 = “.configstoreconfig1.txt”
$filec = “.config.txt”
$result1 = “.resultsapplaunchresult1.txt”
$freq1 = 15
$iterations = 3
function MeasureAppLaunchTime
{
“Number of virtual desktops: $(Get-DesktopCount)”
Sleep 1
“Create a new desktop:”
$NewDesktop = New-Desktop
$OldDesktop = Get-CurrentDesktop
“Number of virtual desktops: $(Get-DesktopCount)”
“Number of new desktop: $(Get-DesktopIndex($NewDesktop))”
“Name of new desktop: $(Get-DesktopName($NewDesktop))”
$index = 1
do {
echo “Running Iteration – $index, Total – $iterations”
Copy-Item $file1 -Destination $filec
$NewDesktop | Switch-Desktop | Start-Process -FilePath .AppTimer.exe -WindowStyle Hidden
Sleep 10
Switch-Desktop $OldDesktop
echo “sleeping for next $freq1 sec”
Start-Sleep $freq1
$index++
} while ($index -le $iterations)
}
config1.txt
C:Program FilesMicrosoft OfficerootOffice16WINWORD.EXE
.resultsapplaunchresult1.txt
Word
1
1000
0 1 0 0
1 1 0
0
0
1
Switch-desktop command switches back and forth to current active desktop which cause end-user to lose access to his current working desktop session for a while. I need to run this script for longer time. I could not find much on the net and seems no switch of start-process launch application in other desktop.
suresh prep is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.