Sign in to follow this  
Followers 0
MykeV

Help! A neeeeewbie who needs guidance.

8 posts in this topic

I am new to scripting (or should i say a virgin compared to some of the scripts i've seen you all put up on this site) so please bear with me.

I have 2 questions...

Question 1

A friend of mine wrote the script below and i am trying to understand it. The script is supposedly looping back to the beginning and running again (it never ends). How is it doing this? Where in the script is this being accomplished? Or does the script end after the first run (there is no looping)? I know the script below is probably childs play to most of you all but i gotta start somewhere :">

; ----------------------------------------------------------------------------

;

; AutoIt Version: 3.1.0

; Author:

;

; Script Function:

; Run Kiosk Presentations with the capabilty to Change Presentation Every few Minutes.

; Runs next file found in the display folder and Copy's it to the child kiosks.

; Updated to remove dos window and run using autoit functions.

; ----------------------------------------------------------------------------

;Copy files on kiosk NCCDISPLAY1

FileCopy("C:\KioskFiles\Display\*.*", "C:\KioskFiles\*.*" , 1 )

Sleep(1000)

;Copy files to kiosk NCCDISPLAY2

FileCopy("C:\kioskfiles\display\*.*", "\\NCCDISPLAY2\KIOSKFILES\Display\*.*" , 1 )

sleep(1000)

;Copy files to kiosk NCCDISPLAY3

FileCopy("C:\kioskfiles\display\*.*", "\\NCCDISPLAY3\KIOSKFILES\Display\*.*" , 1 )

sleep(1000)

;RenameFile

FileMove("C:\kioskfiles\Display\*.*", "C:\Kioskfiles\Display\Display.ppt")

sleep(250)

If FileExists("C:\kioskfiles\display\Display.ppt") Then

ProcessClose("POWERPNT.exe")

sleep(2000)

FileCopy("C:\kioskfiles\display\Display.ppt", "C:\Kioskfiles\running\*.*" , 1 )

;sleep(10000)

Run("C:\Program Files\Microsoft Office\Office11\PowerPNT.exe -s C:\kioskFiles\running\display.ppt")

Else

If ProcessExists("POWERPNT.exe") then

Exit

Else

Run("C:\Program Files\Microsoft Office\Office11\PowerPNT.exe -s C:\kioskFiles\running\display.ppt")

Endif

Endif

If FileExists("C:\kioskfiles\Display.ppt") Then

FileDelete("C:\kioskfiles\Display.ppt")

EndIf

If FileExists("C:\kioskfiles\Display\display.ppt") Then

FileDelete("C:\kioskfiles\Display\display.ppt")

EndIF

-----------------------------------------------------------------------------------------------------------------------------

Question 2

I have a root folder "Folder A". In "Folder A" i have 20 subfolders "Sub-folders 1-20". In each sub-folder lies a file i would like to copy to the root folder "Folder A". What kinda script can i write to accomplish this and can i have the script end after it has copied the last file out of the last folder?

I can do this...

FileCopy (@WorkingDir & "\- MS05-046\*.exe", @WorkingDir)

...but that only copies one file.

Thanks you all for your patient. One day i'll know this stuff like the back of my hand and then I'll be stompin' wit the Big Dawgs!

Share this post


Link to post
Share on other sites



Q1. It seems like the AutoIt compiled script is the PowerPNT.exe that is executed in the script to create the loop cycle of restarting the script.

Q2. Use a script with FileFindFirstFile() and FileFindNextFile() functions to search through each subfolder. If you look in Scripts'n'Scraps, then you would find a FileSearch UDF that is able to search for you also.

If using AutoIt Beta then you could also use Comspec with StdOutRead() or use Com's FileSystemObject's Subfolder property to get the list of subfolders.

Share this post


Link to post
Share on other sites

MykeV,

Welcome to the forum. :whistle:

When you post scripts, you should atleast use a "code" tag at the beginning and a "/code" tag at the end of your code. It makes it much easier to identify as a program. Replace " " with [ ]

Also, I ran "Tidy AutoIt Source" which is found in SciTE under "Tools" which produced the following easier to read and follow code:

; ----------------------------------------------------------------------------
;
; AutoIt Version: 3.1.0
; Author:
;
; Script Function:
; Run Kiosk Presentations with the capabilty to Change Presentation Every few Minutes.
; Runs next file found in the display folder and Copy's it to the child kiosks.
; Updated to remove dos window and run using autoit functions.
; ----------------------------------------------------------------------------

;Copy files on kiosk NCCDISPLAY1
FileCopy("C:\KioskFiles\Display\*.*", "C:\KioskFiles\*.*", 1)
Sleep(1000)

;Copy files to kiosk NCCDISPLAY2
FileCopy("C:\kioskfiles\display\*.*", "\\NCCDISPLAY2\KIOSKFILES\Display\*.*", 1)
Sleep(1000)

;Copy files to kiosk NCCDISPLAY3
FileCopy("C:\kioskfiles\display\*.*", "\\NCCDISPLAY3\KIOSKFILES\Display\*.*", 1)
Sleep(1000)

;RenameFile
FileMove("C:\kioskfiles\Display\*.*", "C:\Kioskfiles\Display\Display.ppt")
Sleep(250)

If FileExists("C:\kioskfiles\display\Display.ppt") Then
    ProcessClose("POWERPNT.exe")
    Sleep(2000)
    FileCopy("C:\kioskfiles\display\Display.ppt", "C:\Kioskfiles\running\*.*", 1)
;sleep(10000)
    Run("C:\Program Files\Microsoft Office\Office11\PowerPNT.exe -s C:\kioskFiles\running\display.ppt")
Else
    If ProcessExists("POWERPNT.exe") Then
        Exit
    Else
        Run("C:\Program Files\Microsoft Office\Office11\PowerPNT.exe -s C:\kioskFiles\running\display.ppt")
    EndIf
EndIf

If FileExists("C:\kioskfiles\Display.ppt") Then
    FileDelete("C:\kioskfiles\Display.ppt")
EndIf

If FileExists("C:\kioskfiles\Display\display.ppt") Then
    FileDelete("C:\kioskfiles\Display\display.ppt")
EndIf

taurus905


"Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

MykeV,

Welcome to the forum. :whistle:

When you post scripts, you should atleast use a "code" tag at the beginning and a "/code" tag at the end of your code. It makes it much easier to identify as a program. Replace " " with [ ]

Also, I ran "Tidy AutoIt Source" which is found in SciTE under "Tools" which produced the following easier to read and follow code:

; ----------------------------------------------------------------------------
;
; AutoIt Version: 3.1.0
; Author:
;
; Script Function:
; Run Kiosk Presentations with the capabilty to Change Presentation Every few Minutes.
; Runs next file found in the display folder and Copy's it to the child kiosks.
; Updated to remove dos window and run using autoit functions.
; ----------------------------------------------------------------------------

;Copy files on kiosk NCCDISPLAY1
FileCopy("C:\KioskFiles\Display\*.*", "C:\KioskFiles\*.*", 1)
Sleep(1000)

;Copy files to kiosk NCCDISPLAY2
FileCopy("C:\kioskfiles\display\*.*", "\\NCCDISPLAY2\KIOSKFILES\Display\*.*", 1)
Sleep(1000)

;Copy files to kiosk NCCDISPLAY3
FileCopy("C:\kioskfiles\display\*.*", "\\NCCDISPLAY3\KIOSKFILES\Display\*.*", 1)
Sleep(1000)

;RenameFile
FileMove("C:\kioskfiles\Display\*.*", "C:\Kioskfiles\Display\Display.ppt")
Sleep(250)

If FileExists("C:\kioskfiles\display\Display.ppt") Then
    ProcessClose("POWERPNT.exe")
    Sleep(2000)
    FileCopy("C:\kioskfiles\display\Display.ppt", "C:\Kioskfiles\running\*.*", 1)
;sleep(10000)
    Run("C:\Program Files\Microsoft Office\Office11\PowerPNT.exe -s C:\kioskFiles\running\display.ppt")
Else
    If ProcessExists("POWERPNT.exe") Then
        Exit
    Else
        Run("C:\Program Files\Microsoft Office\Office11\PowerPNT.exe -s C:\kioskFiles\running\display.ppt")
    EndIf
EndIf

If FileExists("C:\kioskfiles\Display.ppt") Then
    FileDelete("C:\kioskfiles\Display.ppt")
EndIf

If FileExists("C:\kioskfiles\Display\display.ppt") Then
    FileDelete("C:\kioskfiles\Display\display.ppt")
EndIf

taurus905

Try replacing "code" with "autoit". makes it look all pretty-like. Edited by blademonkey

---"Educate the Mind, Make Savage the Body" -Mao Tse Tung

Share this post


Link to post
Share on other sites

Q1. It seems like the AutoIt compiled script is the PowerPNT.exe that is executed in the script to create the loop cycle of restarting the script.

Q2. Use a script with FileFindFirstFile() and FileFindNextFile() functions to search through each subfolder. If you look in Scripts'n'Scraps, then you would find a FileSearch UDF that is able to search for you also.

If using AutoIt Beta then you could also use Comspec with StdOutRead() or use Com's FileSystemObject's Subfolder property to get the list of subfolders.

Mhz, Thanks for the tip on question #2. As for question #1 the Powerpnt.exe is the actual executable for the powerpoint program. So my issue still remains. Is the script in a endless loop or not?

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Try replacing "code" with "autoit". makes it look all pretty-like.

BladeMonkey, Thanks for the tip i'll remember to do that the next time i post a script.

Edited by MykeV

Share this post


Link to post
Share on other sites

MykeV,

Welcome to the forum. :whistle:

When you post scripts, you should atleast use a "code" tag at the beginning and a "/code" tag at the end of your code. It makes it much easier to identify as a program. Replace " " with [ ]

Also, I ran "Tidy AutoIt Source" which is found in SciTE under "Tools" which produced the following easier to read and follow code:

; ----------------------------------------------------------------------------
;
; AutoIt Version: 3.1.0
; Author:
;
; Script Function:
; Run Kiosk Presentations with the capabilty to Change Presentation Every few Minutes.
; Runs next file found in the display folder and Copy's it to the child kiosks.
; Updated to remove dos window and run using autoit functions.
; ----------------------------------------------------------------------------

;Copy files on kiosk NCCDISPLAY1
FileCopy("C:\KioskFiles\Display\*.*", "C:\KioskFiles\*.*", 1)
Sleep(1000)

;Copy files to kiosk NCCDISPLAY2
FileCopy("C:\kioskfiles\display\*.*", "\\NCCDISPLAY2\KIOSKFILES\Display\*.*", 1)
Sleep(1000)

;Copy files to kiosk NCCDISPLAY3
FileCopy("C:\kioskfiles\display\*.*", "\\NCCDISPLAY3\KIOSKFILES\Display\*.*", 1)
Sleep(1000)

;RenameFile
FileMove("C:\kioskfiles\Display\*.*", "C:\Kioskfiles\Display\Display.ppt")
Sleep(250)

If FileExists("C:\kioskfiles\display\Display.ppt") Then
    ProcessClose("POWERPNT.exe")
    Sleep(2000)
    FileCopy("C:\kioskfiles\display\Display.ppt", "C:\Kioskfiles\running\*.*", 1)
;sleep(10000)
    Run("C:\Program Files\Microsoft Office\Office11\PowerPNT.exe -s C:\kioskFiles\running\display.ppt")
Else
    If ProcessExists("POWERPNT.exe") Then
        Exit
    Else
        Run("C:\Program Files\Microsoft Office\Office11\PowerPNT.exe -s C:\kioskFiles\running\display.ppt")
    EndIf
EndIf

If FileExists("C:\kioskfiles\Display.ppt") Then
    FileDelete("C:\kioskfiles\Display.ppt")
EndIf

If FileExists("C:\kioskfiles\Display\display.ppt") Then
    FileDelete("C:\kioskfiles\Display\display.ppt")
EndIf

taurus905

Taurus905, Thanks for the tip. I'll make sure to follow your instructions the next time i post a script.

Share this post


Link to post
Share on other sites

Try replacing "code" with "autoit". makes it look all pretty-like.

blademonkey,

I prefer the code tag over the autoit tag, unless the code is really long. The autoit tag adds a scrollbar but makes it harder to just copy and paste the code to SciTE editor. I found that if you copy scripts posted with the autoit tag, you have to copy and paste it to WordPad and then copy and paste it to SciTE. New users may have trouble until they realize this extra step.

taurus905


"Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0