Skip to content

Instantly share code, notes, and snippets.

@rezarahimian
Created August 18, 2021 19:09
Show Gist options
  • Save rezarahimian/002ebcaf5b2cc9dcd9684bc74e7ab6f5 to your computer and use it in GitHub Desktop.
Save rezarahimian/002ebcaf5b2cc9dcd9684bc74e7ab6f5 to your computer and use it in GitHub Desktop.
Option Explicit
On Error Resume Next
Dim objshell, strPSPath, strPSArg, strScriptFolder
Set objShell = WScript.CreateObject("WScript.Shell")
strPSPath = objShell.ExpandEnvironmentStrings("%SystemRoot%") & "\System32\WindowsPowerShell\v1.0\Powershell.exe"
strScriptFolder = Left(WScript.ScriptFullName, (Len(WScript.ScriptFullName) - (Len(WScript.ScriptName))))
strPSArg = "-ExecutionPolic ByPass -NonInteractive -NoProfile -File " & Chr(34) & strScriptFolder & "Run-LogonScript.ps1" & Chr(34)
objShell.Run Chr(34) & strPSPAth & Chr(34) & Chr(32) & strPSArg, 0, True
Set objshell = Nothing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment