Pages: [1]
Print
Author Topic: VBS wrapper for Scheduling PS scripts  (Read 1790 times)
dma0211
Newbie
*
Posts: 15


View Profile
« on: February 25, 2009, 03:42:24 PM »

Code:
Dim objShell,objFSO,objFile

Set objShell=CreateObject("WScript.Shell")
Set objFSO=CreateObject("Scripting.FileSystemObject")

'enter the path for your PowerShell Script
strPath="C:\yourpowershellscript.ps1"

'verify file exists
If objFSO.FileExists(strPath) Then
'return short path name
set objFile=objFSO.GetFile(strPath)
strCMD="powershell -nologo -command " & Chr(34) & "&{" &_
objFile.ShortPath & "}" & Chr(34)
'Uncomment next line for debugging
'WScript.Echo strCMD

'use 0 to hide window
objShell.Run strCMD,0

Else

'Display error message
WScript.Echo "Failed to find " & strPath
WScript.Quit

End If

« Last Edit: February 26, 2009, 07:28:33 AM by esarakaitis » Logged
esarakaitis
Administrator
Sr. Member
*****
Posts: 256


8223109 sack57@hotmail.com littleking57 rootinfortwayne
View Profile WWW Email
« Reply #1 on: February 26, 2009, 10:11:46 AM »

very nice, i've also used this to call powershell scripts:

Code:
powershell "&""c:\path\to\script.ps1"""


Logged
Pages: [1]
Print
Jump to: