|
-
Aug 10th, 2012, 03:35 PM
#1
Thread Starter
New Member
Launching a script on a remote computer
Ok, I've done some programming but, I'm still new to VB scripting and I've run into a snag.
I've pieced together a few things that appear to be working to the extent I want.
Goal:
1) I activate 1st script that stops all POWERPNT.EXE processes on a remote computer(effectively ending all PPT shows)
2) I upload the new powerpoint show over the old one
3) I activate 2nd script that launches the powerpoint program on the remote computer, then opens the powerpoint show located on the remote computer
(I am doing 2 launches so that it shows in the foreground, when testing if I launched the show directly it would show, but in the background and I would have to click on it to have it in the active window, I want it fully automated)
End Task Code:
Code:
on error resume next
set ppt = getobject(,"powerpoint.application")
if Err.number = 0 then
For each pres in ppt.presentations
pres.close
next
ppt.quit
End If
Launch PPT Show Code:
Code:
Set Command = WScript.CreateObject("WScript.Shell")
cmd = """C:\Program Files\Microsoft Office\Office14\POWERPNT.exe"""
Command.Run (cmd)
Set objPPT = CreateObject("PowerPoint.Application")
objPPT.Visible = True
Set objSlideShow = objPPT.Presentations.Open("C:\Users\User\Documents\Support Presentation\SupportTVPresentation.pps")
So both of these work great when executed on the computer directly but, I can't get them to run remotely.
I've been attempting to set them up as scheduled tasks that run one minute later but, they aren't executing properly or something, when I try to create them on my local computer they wont execute.
I'm not sure if its a permissions thing, or if I need to run the task as admin instead of system which I'm not sure what command would do that.
Code:
strComputer = "supmedia1-dt"
strCommand = "C:\Users\User\Documents\KILLPPT.VBS"
Const INTERVAL = "n"
Const MINUTES = 1
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objScheduledJob = objWMIService.Get("Win32_ScheduledJob")
Set objSWbemDateTime = CreateObject("WbemScripting.SWbemDateTime")
objSWbemDateTime.SetVarDate(DateAdd(INTERVAL, MINUTES, Now()))
errReturn = objScheduledJob.Create(strCommand, objSWbemDateTime.Value, False, 0, 0, True, intJobID)
If errReturn = 0 Then
Else
Wscript.Echo "PPT Start could not be started due to error: " & errReturn
End If
Am I close and just missing a line? is there a better way to do this? or is there a way to run as credentials when creating the task, any insights in this would be much appreciated.
Thanks ahead of time!
-Marshall
Last edited by mbdean; Aug 11th, 2012 at 03:57 PM.
Reason: Edited code error
-
Aug 10th, 2012, 03:40 PM
#2
Thread Starter
New Member
Re: Launching a script on a remote computer
*corrected original post*
Last edited by mbdean; Aug 11th, 2012 at 03:56 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|