Need Help Writing a Script

Discussion in 'OT Technology' started by FoCaL, Aug 31, 2004.

  1. FoCaL

    FoCaL New Member

    Joined:
    Oct 22, 2003
    Messages:
    111
    Likes Received:
    0
    Location:
    St. Louis
    I guess Ill give some background on the project. Here at my company the Marketing Dept., with the help of the IS Dept. setup at least one computer at every branch. This computer is hooked up to a TV, or several TV's in some cases and the computer runs a Power Point to help keep employees up to date on my company's news. Well currently when they update the power point presentation they have to logon to every computer at every branch and download the new power point. Then stop the old one and start the new one. I'm trying to make this 30 - 45 minute weekly job about 2.

    What I have so far is code that opens a browser so they can browse their computer and the network and select the newest power point file. Then I have the program stopping the power point process on the remote computers so I can copy over the old file. After that I do that copy, and I then would like to start power point and then start the slide show in power point. I'm stuck at starting the power point remotely. I can start power point fine, however it always starts as a background process and you only see power point running in task manager under processes. So I thought well I can make two scripts. Id prefer one but if two will work then so be it. So I wrote some cheap little code that does some send keys thinking Ill put that on the computer then start it remotely. Well I can start it remotely but it also stays in the background and you never see power point open on the console, just running in task manager.

    Ive tried modifying my script accordingly so that it should start up in the forground but I cant get it to work correclty. Anyone want to give me a hand? Im open to just about anything that will make this work for me. I can provide my code or parts of my code if needed, just let me know what you need to know. Thanks in advance.
     
  2. FoCaL

    FoCaL New Member

    Joined:
    Oct 22, 2003
    Messages:
    111
    Likes Received:
    0
    Location:
    St. Louis
    Not everyone post to try and help at once ;)

    Ill go over what I have coded again quickly, maybe I was to elaborate above.

    On my computer I run the program
    It prompts me to pick my power point file
    Once the file is selected it stopps the power point process on the remote computers
    Now it copies the power point to the remote computers renaming the file to a standard convention and overwriting the old one

    Thats what I have done so far and that obviously in laymens terms. My next step is to start power point remotely, since the script is running on my computer. Ive gotten it to work, it will start power point. However, as I stated above it starts as a background process and you cannot see it on the console. Ive done some reserch and found out a method that is supposed to make it start in the forground, but I cant get it to work right.

    This is the code that starts the process. However it does start in the background with this code. This code does work correclty.

    Code:
    strComputer = "testsvr90"
    Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2:Win32_Process")
    errReturn = objWMIService.Create("C:\FHN\current.ppt", null, null, intProcessID)
    If errReturn = 0 Then
    Wscript.Echo "Power Point was started with a process ID of " & intProcessID & "."
    Else
    Wscript.Echo "Power Point could not be started due to an error " & errReturn & "."
    End If
    This is the modified code thats supposed to let it start in the forground. This code does NOT work correclty. I get an error return or 'Error 8'

    Code:
    const ShowWin = 5
    Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\testsvr90\root\cimv2")
    Set objStartup = objWMIService.Get("Win32_ProcessStartup")
    Set objConfig = objStartup.SpawnInstance_
    objConfig.ShowWindow = ShowWin
    Set objProcess = GetObject("winmgmts:{impersonationLevel=impersonate}!\\testsvr90\root\cimv2:Win32_Process")
    errReturn = objProcess.Create("C:\FHN\POWERPNT.EXE", Null, Null, intProcessID)
    If errReturn = 0 Then
    Wscript.Echo "Power Point was started with a process ID of " & intProcessID & "."
    Else
    Wscript.Echo "Power Point could not be started due to an error " & errReturn & "."
    End If
    edit: I just got the second code to work without returning an error. However, it still start Power Point on the remote machine as a brackground process and you can only see power point running in task manager.
     
  3. 5Gen_Prelude

    5Gen_Prelude There might not be an "I" in the word "Team", but

    Joined:
    Mar 14, 2000
    Messages:
    14,519
    Likes Received:
    1
    Location:
    Vancouver, BC, CANADA
    OKay, if it was me, I would use the scheduler and batch files. I'd run the batch file every x number of hours, check an ftp server for the newest file, compare it with what is running, if it's different, send a kill command to the powerpoint project, delete the old file, rename the new file to the old file name, and use the start command to start the pps file back up. Also have the computer run the pps file whenever someone logs in.
     
  4. FoCaL

    FoCaL New Member

    Joined:
    Oct 22, 2003
    Messages:
    111
    Likes Received:
    0
    Location:
    St. Louis
    I wouldnt mind doing that but I want it to update when I tell it to ... Not when its scheduled to. If there is no new file, then theres no reason for it to update. And if I have a new file I dont want to wait till the next time its scheduled to run before it will update. Thanks for the thoughts though at this rate I may end up doing what you suggested.
     
    Last edited: Sep 1, 2004
  5. schmack

    schmack Professional Lurker OT Supporter

    Joined:
    Mar 12, 2003
    Messages:
    1,667
    Likes Received:
    16
    Why not just do a web presentation? Once you update the server side stuff, wouldn't everybody see the same thing? Are the PC's just not hooked to the internet?
     
  6. FoCaL

    FoCaL New Member

    Joined:
    Oct 22, 2003
    Messages:
    111
    Likes Received:
    0
    Location:
    St. Louis
    They are hooked to the inet ... and I tried to get a web presentation as the method to use over power point. The problem was Im not doing the updating and I dont have time to. the ones who are would have no idea how to do that. Plus a web presentation uses bandwidth on our frame and point to point connections. The plenty of overhead, but we wanted to try and stay away from using that overhead.
     

Share This Page