3

In the case where hibernation is not possible, after turn off and turn on the computer would be useful have a script to reconfigure the system as it was before:

How to write a script to launch multiple applications in multiple desktops in Windows 10 ?

To do this the key is to create Virtual Desktops in the script.

It Would be preferably to do that using commands from the PowerShell.

Update

A general look in the procedure:

To use the PowerShell IDE, as it allows to write the script and to run commands and scrits in the same environment.

Procedure to create the script:

  1. To insert the path and file of the executable (taked from shortcuts);
  2. To insert delay
  3. To create a new Virtual Desktop (preferably using PowerShell commands);
  4. To insert delay
  5. Repeat

Procedure to run the script:

  1. Set-ExecutionPolicy RemoteSigned
  2. To run the script
  3. Set-ExecutionPolicy Restricted

How to create Virtual Desktops using PowerShell commands ?

2
  • The answer here on the very same question was voted useful. Give it a try. Nov 3, 2015 at 3:44
  • The a idea (described by @Shaun Webb) is to open apps running a script with the sequence of apps calls plus a line to do a delay and a call to create the Virtual Desktop, for exemple: calc Start-Sleep -Milliseconds 500 [CSharpPS.PS]::NewVD() Start-Sleep -Milliseconds 500 notepad. For create a Virtual Desktops they used a script based in the Input Simulator project (inputsimulator.codeplex.com). I not yet tried the script. Nov 3, 2015 at 14:13

1 Answer 1

3

WIN + CTRL + D: Create a new desktop

$KeyShortcut = Add-Type -MemberDefinition @"
[DllImport("user32.dll")]
static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, UIntPtr dwExtraInfo);
//WIN + CTRL + D: Create a new desktop
public static void CreateVirtualDesktopInWin10()
{
    //Key down
    keybd_event((byte)0x5B, 0, 0, UIntPtr.Zero); //Left Windows key 
    keybd_event((byte)0x11, 0, 0, UIntPtr.Zero); //CTRL
    keybd_event((byte)0x44, 0, 0, UIntPtr.Zero); //D
    //Key up
    keybd_event((byte)0x5B, 0, (uint)0x2, UIntPtr.Zero);
    keybd_event((byte)0x11, 0, (uint)0x2, UIntPtr.Zero);
    keybd_event((byte)0x44, 0, (uint)0x2, UIntPtr.Zero);
}
"@ -Name CreateVirtualDesktop -UsingNamespace System.Threading -PassThru
   $KeyShortcut::CreateVirtualDesktopInWin10()

More details How to create new Virtual Desktop in Windows 10 using PowerShell

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .