Because I have to wrap parameters in double quotes, do I double the quotes
around the whole statement like this:
'Run the PowerPoint presentation on the 047-GRAPEVINE computer using
psexec.exe
WShell.Run ""psexec \\047-GRAPEVINE "C:\Program Files\Microsoft
Office\Office\Powerpnt.exe" /s C:\grapevine\ & filename & ".ppt"""
I do not think that psexec.exe is suitable for this task - it only
works in a Command Prompt environment. PowerPoint requires
a GUI. Perhaps "objWMIService.Create" would work in this
case.
Thanks, I'll look into this. But powerpoint can be run from the cmd line.
The idea is for our secretary to be able to copy a powerpoint presentation
to a headles computer (that's connected to our television sets) and then
force the remote computer to run the presentation. Jeremy
I am aware that PowerPoint can be invoked from the Command
Prompt. However, if the current shell does not support a GUI
environment then you won't see anything on the screen.
Your first job should be to test your proposed solution directly,
not from within a script. You can do it like so:
- Run psexec.exe \\remotepcd cmd
- CD to C:\Program Files\Microsoft Office11\Office
- Manually copy your .ppt file to the current folder.
- Open the file: PowerPnt.exe MyFile.ppt.
- Can your secretary see the file? I doubt it very much.
If she can then you can start worrying about quotes
and scripts.
"Pegasus (MVP)" wrote:
The secretary is the creator of the daily powerpoint, yes, she can see it.
I just want it to be as simple a process for her as possible. I don't want
to have to (and she won't want to) start learning how to run the cmd line
stuff. So I have come up with this script so far. I will Google to see what
to do about the double quotes.
Dim filename
Set WShell = CreateObject("WScript.Shell")
Const OverwriteExisting = True
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Get the name of the PowerPoint presentation
filename = Inputbox("Enter the name of the PowerPoint." & VBcrLF & "One word
only, no spaces." & VBCrLf & "And do not enter the extension (.ppt)","Enter
Name")
'Reboot 047-GRAPEVINE to end the powerpnt process
WShell.Run "shutdown \\047=GRAPEVINE /r /t:20 /y /c"
'Sleep for 5 minutes while 047-GRAPEVINE reboots
WScript.Sleep 300000
'Copy the PowerPoint presentaton to the 047-GRAPEVINE computer
objFSO.CopyFile "h:\grapevine\" & filename &
".PPT","\\047-GRAPEVINE\grapevine$\", OverwriteExisting
Dim filename
Set WShell = CreateObject("WScript.Shell")
Const OverwriteExisting = True
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Get the name of the PowerPoint presentation
filename = Inputbox("Enter the name of the PowerPoint." & VBcrLF & "One word
only, no spaces." & VBCrLf & "And do not enter the extension (.ppt)","Enter
Name")
'Kill the existing PowerPoint presentation
WShell.Run "c:\psexec \\047-GRAPEVINE c:\grapevine\pskill powerpnt.exe"
'Reboot 047-GRAPEVINE to end the powerpnt process
'WShell.Run "shutdown.exe -m \\047-GRAPEVINE -r"
'Sleep for 5 minutes while 047-GRAPEVINE reboots
'WScript.Sleep 300000
'Sleep for 5 minutes while 047-GRAPEVINE reboots
'WScript.Sleep 300
'Copy the PowerPoint presentaton to the 047-GRAPEVINE computer
objFSO.CopyFile "h:\grapevine\" & filename &
".PPT","\\047-GRAPEVINE\grapevine$\", OverwriteExisting
'Run the PowerPoint presentation on the 047-GRAPEVINE computer using
psexec.exe
'WShell.Run "c:\psexec.exe \\047-GRAPEVINE" & " powerpnt.exe /s" &
"c:\grapevine\" & filename & ".ppt"""
strComputer = "047-GRAPEVINE"
Set objWMIService = GetObject("winmgmts:" &
"{impersonationLevel=impersonate}!\\" & strComputer &
"\root\cimv2:Win32_Process")
Error = objWMIService.Create("powerpnt.exe /s c:\grapevine\" & filename &
".ppt", null, null, intProcessID)
If Error = 0 Then
Wscript.Echo "PowerPoint was started with a process ID of " & intProcessID &
"."
Else
Wscript.Echo "PowerPoint could not be started due to error " & Error & "."
End If
"How Can I Remotely Start an Interactive Process?"
http://www.microsoft.com/technet/scriptcenter/resources/qanda/sept05/hey0906.mspx
As the article points out, the only way around this problem is to
launch a scheduled job, which adds another level of complexity.
This might be a good time for you to explain what you're actually
trying to achieve, why you're attempting to kill the existing PowerPoint
application and why you're trying to reboot the remote computer.
By the way, there is little point in using psexec.exe, then pskill.exe
to kill a remote process. You can use pskill.exe directly - it has a
switch to address remote machines.
About your original question regarding double quotes: You can
allow your users to specify file names with embedded spaces if
you code your command like so:
objWMIService.Create("powerpnt.exe /s ""c:\grapevine\" & filename &
".ppt""", null, null, intProcessID)
"Jeremy" <Jer...@discussions.microsoft.com> wrote in message
news:67DF466B-1409-47E2...@microsoft.com...
The remote box is actually W2K and the article only mentions XP and 2003.
So I may be ok here.
> This might be a good time for you to explain what you're actually
> trying to achieve, why you're attempting to kill the existing PowerPoint
> application and why you're trying to reboot the remote computer.
I left some things commented out just so I could remember the syntax if I
wanted to reincorporate them. But here's my basic logic.
Our secretary receives the daily student newsletter as a Word doc and she
creates a PowerPoint with that infl. From her computer, the PowerPoint
needs to get on to the headless computer. The video card on the headless
computer is connected to televisions in the school...She had been using
Dameware, but sometimes that setup confuses her. So I wanted to create a
script that would automate things for her. So she only had to type in the
name of the power pooint and click on go. One thing that was causing a
problem was that Monday's powerpoint would have to be stopped in order for
her to start Tuesday's power point. I have the remote computer (w2k) set to
autologon. So then I began to experiment with pskill and rebooting the
machine to stop the existing powerpoint so the new one could be started.
> By the way, there is little point in using psexec.exe, then pskill.exe
> to kill a remote process. You can use pskill.exe directly - it has a
> switch to address remote machines.
Thank you for that info.
> About your original question regarding double quotes: You can
> allow your users to specify file names with embedded spaces if
> you code your command like so:
>
> objWMIService.Create("powerpnt.exe /s ""c:\grapevine\" & filename &
> ".ppt""", null, null, intProcessID)
Again, thank you.
"Jeremy Schubert" <jscc-...@hotmail.com> wrote in message
news:69277A07-4FC8-4FBF...@microsoft.com...
> Thank you Pegasus,
> I've briefly looked at the article.
>> It appears that there is a big obstacle in your way: WinXP does not
>> allow you to start an interactive process remotely. Have a look here:
>>
>> "How Can I Remotely Start an Interactive Process?"
>> http://www.microsoft.com/technet/scriptcenter/resources/qanda/sept05/hey0906.mspx
>
> The remote box is actually W2K and the article only mentions XP and 2003.
> So I may be ok here.
Your chances are about as good as expecting the Mississippi to
flow uphill. Older OSs invariably have less connectivity, not more.
>> This might be a good time for you to explain what you're actually
>> trying to achieve, why you're attempting to kill the existing PowerPoint
>> application and why you're trying to reboot the remote computer.
>
> I left some things commented out just so I could remember the syntax if I
> wanted to reincorporate them. But here's my basic logic.
> Our secretary receives the daily student newsletter as a Word doc and she
> creates a PowerPoint with that infl. From her computer, the PowerPoint
> needs to get on to the headless computer. The video card on the headless
> computer is connected to televisions in the school...She had been using
> Dameware, but sometimes that setup confuses her. So I wanted to create a
> script that would automate things for her. So she only had to type in the
> name of the power pooint and click on go. One thing that was causing a
> problem was that Monday's powerpoint would have to be stopped in order for
> her to start Tuesday's power point. I have the remote computer (w2k) set
> to autologon. So then I began to experiment with pskill and rebooting the
> machine to stop the existing powerpoint so the new one could be started.
There is a far simpler way:
1. Use pskill.exe to kill power point on the headless machine.
2. Copy the file to the headless machine, using copy or xcopy.
3. Reboot the headless machine, using psshutdn.exe.
You can do all of the above in a 3-line batch file.
On the headless machine you must arrange for two things:
a) It must auto-logon.
b) There must be a link in the Startup folder that launches
PowerPoint and opens your file.
Nice'n'easy, no problem!
All of the above can be done in a simple batch file. The secretary
does not need to do anything, other than creating the PowerPoint
file from the newsletter.
@echo off
xcopy /d /L \\secretary\somefolder\somefile.ppt | find /i "1 file" || goto
:eof
taskkill /im powerpnt.exe
xcopy /d /y \\secretary\somefolder\somefile.ppt
"c:program files\microsoft office\office11\powerpnt.exe" d:\newsletter.ppt
"Jeremy Schubert" <jscc-...@hotmail.com> wrote in message
news:69277A07-4FC8-4FBF...@microsoft.com...
"Jeremy Schubert" <jscc-...@hotmail.com> wrote in message
news:eXoQnzKG...@TK2MSFTNGP06.phx.gbl...