How to use paths with pauses in PowerShell code inserted to VBS file?

Microsoft Windows
SS##66
Posts: 28
Joined: 2023-Jan-24, 4:51 pm

Re: How to use paths with pauses in PowerShell code inserted to VBS file?

Post by SS##66 »

You are right

Kudos
Pranav
Posts: 4
Joined: 2023-Nov-30, 9:14 am
Contact:

Re: How to use paths with pauses in PowerShell code inserted to VBS file?

Post by Pranav »

To include pauses in PowerShell code inserted into a VBS (VBScript) file, you can use the `Start-Sleep` cmdlet in PowerShell to introduce delays. Here's an example of how you might structure it:

```powershell
# PowerShell code with pauses
$code = @"
# Your PowerShell code here
Write-Host "Executing Step 1"
Start-Sleep -Seconds 5
Write-Host "Executing Step 2"
Start-Sleep -Seconds 10
Write-Host "Executing Step 3"
"@

# Save the PowerShell code to a VBS file
$code | Out-File -FilePath "C:\Path\To\Your\Script.vbs"
```

In this example, the `Start-Sleep` cmdlet is used to introduce pauses between different steps in your PowerShell code. Adjust the `-Seconds` parameter to specify the duration of the pause in seconds.

This PowerShell script will then be saved to a VBS file, which can be executed using the Windows Script Host (`cscript.exe` or `wscript.exe`). Remember to change the file path to your desired location.
SS##66
Posts: 28
Joined: 2023-Jan-24, 4:51 pm

Re: How to use paths with pauses in PowerShell code inserted to VBS file?

Post by SS##66 »

Thank you

I will try this out when and if I will have time to get back to this issue
Post Reply