/build/static/layout/Breadcrumb_cap_w.png

presentation share script

Hi all..

I'm still a newbie at VB script, and i've got a question regarding it.. This is the current situation:

I have 2 network shares. I need to have a script checking share #1, checking if it contains a powerpoint presentation, say every 5 minutes. This a not the real issue, I could schedule the script to run every 5 minutes. If share#1 does contain a presentation, it should:
- stop the current presentation running in powerpoint, from share#2;
- move presentation from share #1 to share #2 (overwriting the current presentation);
- start the new presentation using powerpoint;

Sounds pretty easy to do, but if your not that experienced with VBS yet (like me.. [:D]) it can become be a challenge.. What do i have
thusfar? Well:

[update]

Dim WshShell

Set WshShell = WScript.CreateObject("WScript.Shell")
Share1 = ("H:\1\presentatie.pst")
Share2 = ("H:\2\presentatie.pst")

On Error Resume Next
Dim fs
Set fs = CreateObject("Scripting.FileSystemObject")
If Not fs.FileExists("presentatie.pps") Then
'do nothing, file is not found
Msgbox "file is not found"
Else
'stop powerpoint, move presentation and start new presentation
Msgbox "Stop powerpoint, move new presentation and start it.."
WSHShell.Run"C:\WINDOWS\system32\taskkill.exe /F /IM POWERPNT.EXE"
FileCopy "H:\1\presentatie.pps", "h:\2\presentatie.pps"
Kill "presentatie.pps"
End if
Wscript.Quit(0)

[/update]
Anyhow, the script runs till the filecopy command. No error whatsoever, just doesn't move the presentations. Does kill powerpoint though. Any suggestions..?

0 Comments   [ + ] Show comments

Answers (1)

Posted by: Garrett 19 years ago
Orange Belt
0
The code below should work, although i have not tested it. Either way it will point you in the right direction.

This book helped me a TON when I started with vbscript. I highly recommend it.

If you have any questions or the script gives you some problems please reply in the forums and I'll give you a hand.


'I debug script with out On Error Resume Next
'When the script goes into prod your can uncomment it to make sure it keeps running.
'On Error Resume Next

Dim Share1, Share2, ppsName, sleepTime, StrComputer, objWMIService

'Scripting objects
Set objShell = Wscript.CreateObject("Wscript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objNetwork = Wscript.CreateObject("Wscript.Network")

Const OverWriteFiles = True
strComputer = "."

'In milliseconds
'1 second - 1000
'1 minute - 60000
'5 minutes - 300000
sleepTime = 300000

Share1 = "\\Server\Share1\"
Share2 = "\\Server\Share2\"

ppsName = "presentation.pps"

Main 'Call the Main() Sub to start the script.

Sub Main
If objFSO.FileExists(Share1 & ppsName) Then
KillPowerpoint 'Kill Powerpoint with the KillPowerpoint Sub
MoveThePPS 'Move the pps with the MoveThePPS Sub
StartPowerpoint ' Start Powerpoint with the StartPowerpoint Sub
End If
Wscript.Sleep sleepTime
Main ' Calls itself again to start the loop over.
End Sub 'Main

Sub MoveThePPS
objFSO.MoveFile(Share1 & ppsName, Share2 & ppsName, OverWriteFiles)
End Sub 'CopyThePPS

Sub KillPowerpoint
Dim colProcessList, objProcess
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcessList = objWMIService.ExecQuery("Select * from Win32_Process Where Name = 'POWERPNT.EXE'")
For Each objProcess in colProcessList
objProcess.Terminate()
Next
End Sub 'KillPowerpoint

Sub StartPowerpoint
objShell.Run Share2 & ppsName & "/y" '
End Sub 'StartPowerpoint
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

View more:

Share

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ