-
Notifications
You must be signed in to change notification settings - Fork 0
/
WallpaperChanger.vbs
817 lines (609 loc) · 27.5 KB
/
WallpaperChanger.vbs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
' VBScript File
Option Explicit
'--------------------------------------------------------------
' REFERENCES
'--------------------------------------------------------------
'
' Expected configuration settings file contents should be:
' configcontents(0) = "Get New Images From This Directory:"
' configcontents(1) = {The configured Wallpaper Source Directory}
' configcontents(2) = vbNewLine
' configcontents(3) = "Store Current Wallpaper Images in This Directory:"
' configcontents(4) = {The configured Wallpaper Destination Directory}
' configcontents(5) = vbNewLine
' configcontents(6) = "Keep This Number of Wallpaper Images"
' configcontents(7) = {The number of images to store}
' configcontents(8) = vbNewLine
' configcontents(9) = "Wallpaper Last Changed:"
' configcontents(10) = {Timestamp of last change}
'
'
' Log Text Sample
' Message type is bracket + 20 characters + bracket
' [tab]
' Timestamp is bracket + 14 characters + bracket
' [tab]
' Message
'
' [Message Type 20 Char] [timestamp] Message
'---------------------------------------------------------------
' END REFERENCES
'---------------------------------------------------------------
'---------------------------------------------------
' Define variables used in script
'---------------------------------------------------
' Dim
' colFolders, _
Dim _
colSubfolders, _
configcontents(), _
configsourcepath, _
configdestpath, _
configkeepimages, _
configkeepimages_orig, _
configexists, _
da, _
defFile, _
DestFolder, _
DestinationFolder, _
edate, _
error, _
errorcount, _
expLines, _
extName, _
file, _
folderPath, _
ForAppending, _
ForReading, _
ForWriting, _
foundlines, _
FSO, _
ho, _
i, _
j, _
logcontents, _
logDirectory, _
logexists, _
logFile, _
logText, _
max, _
mi, _
min, _
mo, _
moday, _
MyFiles, _
NewFileName, _
objFile, _
objFolder, _
objFSO, _
objLogFile, _
objNet, _
objReadFile, _
objShell, _
objStream, _
objSubfolder, _
objWallFile, _
objWMIService, _
ofolder, _
oSHApp, _
scriptDirectory, _
scriptPath, _
sdate, _
se, _
selectedwallpaper, _
SlideShow, _
SlideFolder, _
SourceFolder, _
SPath, _
strComputer, _
strDesktop, _
subFolder, _
sUserName, _
sWallPaper, _
sWinDir, _
temp, _
temp1, _
temp2, _
therand, _
timestamp, _
userreply, _
varPathCurrent, _
wallFile, _
wallText, _
ye
'-------------------------
' Set script-level variables
'-------------------------
errorcount=0
' Create the File System Objects
Set FSO = CreateObject("Scripting.FileSystemObject")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objNet = CreateObject("WScript.Network")
Set objShell = CreateObject("WScript.Shell")
Set oSHApp = CreateObject("Shell.Application")
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
' Assign the file open/read variables (That won't be changed later in the program)
ForAppending = 8
ForReading = 1
ForWriting = 2 'ForWriting will delete the existing contents before writing to the file
' Find the path the the current WallpaperChanger script.
scriptPath = Left(WScript.ScriptFullName, InstrRev(WScript.ScriptFullName, WScript.ScriptName) -1)
' This is the path where the configuration settings file will be found (or created).
scriptDirectory = scriptPath
' Assigns the filename and path to search for or create the configuration settings file
wallFile = "WallpaperChanger Settings.txt"
' Date variables
ye = Year(Now())
mo = Month(Now())
da = Day(Now())
ho = Hour(Now())
mi = Minute(Now())
se = Second(Now())
if (mo<10) then
mo = "0" & mo
else
mo = "" & mo
end if
if (da<10) then
da = "0" & da
else
da = "" & da
end if
if (ho<10) then
ho = "0" & ho
else
ho = "" & ho
end if
if (mi<10) then
mi = "0" & mi
else
mi = "" & mi
end if
if (se<10) then
se = "0" & se
else
se = "" & se
end if
timestamp = ye & mo & da & ho & mi & se
On Error Resume Next
Err.Clear
'-------------------------
' Read the contents of the configuration settings file (or create a new file)
'-------------------------
' Call a function to read the contents of the configuration settings file (or create one if it does not exist
' or if it is invalid.
GetSetConfigFile()
'-------------------------
' Call the Verify function to determine whether the configuration settings file was built correctly.
'-------------------------
VerifyConfigSettingsFileLines
'-------------------------
' DEBUGGING: Is there a verified configuration file?
' WScript.Echo "Configuration file exists? " & configexists
'-------------------------
'-------------------------
' If file verifies, call a function to read it. Otherwise, call a function to re-create the file.
'-------------------------
if (explines = foundlines) then
' If the file passes verification, read the file
ReadWallFile
else
' If size indicates an error in wallFile, call CreateConfigurationSettingsFile function to recreate it
WScript.Echo "An error has occured with the configuration file: " & vbNewLine & scriptDirectory & wallFile _
& vbNewLine & "Executing built-in pause for 5 seconds to rebuild file."
WScript.Sleep(2500)
' Only if creating it works
'CreateConfigurationSettingsFile
' Otherwise, just modify it
ModifyConfigurationSettingsfile
end if
'-------------------------
' DEBUGGING: Display configcontents
' i=0
' While i<UBound(configcontents)
' WScript.Echo configcontents(i)
' i=i+1
' Wend
'-------------------------
'-------------------------
' Choose the new wallpaper
'-------------------------
' Call a function to randomly select a new wallpaper for the user.
selectedwallpaper = SelectNewWallpaper
'-------------------------
' Set the new wallpaper
'-------------------------
' Copy the new wallpaper into the destination wallpaper folder
CopyNewWallpaper
' Exit the application
WScript.Quit
'------------------------------------------
' FUNCTIONS
'------------------------------------------
Function GetSetConfigFile ()
' This function reads the contents of the Wallpaper Changer Configuration settings file.
' If no settings file exists, the user is prompted to create a new configuration settings file.
'-------------------------
' DEBUGGING:
' WScript.Echo "Function GetSetConfigFile called"
'-------------------------
On Error Resume Next
Err.Clear
'---------------------
' Look for the configuration settings file.
' If no configuration settings file exists, call another function to create and configure one now.
'---------------------
if objFSO.FolderExists(scriptDirectory) then
Set objFolder = objFSO.GetFolder(scriptDirectory)
' Folder exists!
' This is redundant, as the configuration settings file path is automatically the path to this
' script itself. But I left it in in case I decide to allow the user to store the configuration
' settings file in a different location someday.
else
Set objFolder = objFSO.CreateFolder(scriptDirectory)
' If the configuration settings file's parent folder does not exist, it will be created here.
'-------------------------
' OPTION: Uncomment the line below if you want the script to notify the user that the folder was created.
'-------------------------
' WScript.Echo "Successfully installed configuration directory: " & scriptDirectory
end if
' In either case above, the folder exists. Now, we look for the file itself.
' If it doesn't exist, we'll create it now and call the configuration function to prompt the user for input.
if NOT(objFSO.FileExists(scriptDirectory & wallFile)) then
CreateConfigurationSettingsFile
' Call the function that creates the configuration settings file.
' NOTE: The CreateConfigurationSettingsFile will, in turn, call a separate script which will allow the user to
' review and modify the configuration settings for the program.
' Upon successful completion of the script, configexists variable is set to true.
end if
Set objFile = Nothing
Set objFolder = Nothing
End Function
Function VerifyConfigSettingsFileLines ()
' This function will read the number of lines in the configuration settings file. If the number of lines in the file
' matches the number of expected lines, we can assume the configuration settings file was written correctly.
'-------------------------
' DEBUGGING:
' WScript.Echo "Function VerifyConfigSettingsFileLines called"
'-------------------------
On Error Resume Next
Err.Clear
'-------------------------
' Set the number of lines you expect to see in the configuration settings file
'-------------------------
foundlines = 0
explines = 11
'-------------------------
' Count the number of lines (i) in the existing configuration settings file
'-------------------------
Set objWallFile = objFSO.OpenTextFile (scriptDirectory & wallFile, ForReading)
i = 0
Do Until objWallFile.AtEndOfStream
temp = objWallFile.ReadLine
i=i+1
Loop
objWallFile.close
set objWallFile = Nothing
' Store the number of lines found into a variable for later use
foundlines = i
'-------------------------
' DEBUGGING:
' WScript.Echo "Expected Lines: " & explines & chr(13) & "Found Lines: " & foundlines
'-------------------------
End Function
Function ReadWallFile ()
' This function will read the configuration settings file and store each line in the array configcontents.
'-------------------------
' DEBUGGING:
' WScript.Echo "Function ReadWallFile called"
'-------------------------
On Error Resume Next
Err.Clear
' If configuration settings file exists and passes verification, read it
Set objWallFile = objFSO.OpenTextFile (scriptDirectory & wallFile, ForReading)
i=0
'Save each line into an array variable
Do Until objWallFile.AtEndOfStream
Redim Preserve configcontents(i)
configcontents(i) = objWallFile.ReadLine
' msgbox(configcontents(i))
i=i+1
Loop
' Close the file
objWallFile.close
Set objWallFile = Nothing
if (configcontents(1) > "" AND configcontents(4) > "" AND configcontents(7) > "") then
' Set the path to the wallpaper source folder
configsourcepath = configcontents(1)
' Set the path to the wallpaper destination folder
configdestpath = configcontents(4)
' Set the number of images to keep
configkeepimages = configcontents(7)
if (configkeepimages="" OR configkeepimages="0") then
configkeepimages="10"
end if
if (CInt(configkeepimages)<10) then
configkeepimages = "0" & configkeepimages
end if
configkeepimages_orig = CInt(configkeepimages)
' configposition = configcontents(7)
' configslideshow = configcontents(10)
' If file exists, passes verification, and contains acceptable entries, let the program know it exists
configexists = true
else
configexists = false
end if
End Function
Function CreateConfigurationSettingsFile()
' This function will create a new configuration settings file and call a separate script to allow the user to review and modify
' the configuration settings for the program.
On Error Resume Next
Err.Clear
'-------------------------
' DEBUGGING:
' WScript.Echo "Function CreateConfigurationSettingsFile called"
'-------------------------
Set objWallFile = objFSO.CreateTextFile (scriptDirectory & wallFile, ForWriting)
objWallFile.WriteLine("Get New Images From This Directory:")
objWallFile.WriteLine("C:\Users\" & objNet.UserName & "\Pictures\Wallpaper_Source")
objWallFile.WriteLine("")
objWallFile.WriteLine("Store Current Wallpaper Images in This Directory:")
objWallFile.WriteLine("C:\Users\" & objNet.UserName & "\Pictures\Wallpaper_Destination")
objWallFile.WriteLine("")
objWallFile.WriteLine("Keep This Number of Wallpaper Images:")
objWallFile.WriteLine("5")
objWallFile.WriteLine("")
objWallFile.WriteLine("Wallpaper Last Changed:")
objWallFile.WriteLine("")
'-------------------------
' DEBUGGING:
' WScript.Echo "New configuration file successfully created." & chr(13) & "Function ModifyConfigurationSettingsFile called"
'-------------------------
ModifyConfigurationSettingsFile
End Function
Function ModifyConfigurationSettingsFile()
' This function will call an external script to allow the user to review and modify the configuration settings file.
On Error Resume Next
Err.Clear
'-------------------------
' DEBUGGING:
' WScript.Echo "Function ModifyConfigurationSettingsFile called"
'-------------------------
' Calls a separate script to allow the user to review and modify the configuration settings for the program.
temp = """" & scriptPath & "\WallpaperChanger_Config.vbs"""
WScript.Echo "This is where the old wallpaper changer config would run...currently disabled"
'objShell.Run(temp)
End Function
Function SelectNewWallpaper()
' This function will find an appropriate wallpaper based on the user's preferred directory and any date-specific
' wallpaper preferences and copy it to the destination directory.
'-------------------------
' DEBUGGING:
' WScript.Echo "Function SelectNewWallpaper called"
'-------------------------
On Error Resume Next
Err.Clear
if (configexists = true) then
' Verify that the selected wallpaper directory actually exists.
' If not, then give user the option to adjust settings or quit program
If (objFSO.FolderExists(configsourcepath) AND objFSO.FolderExists(configdestpath)) then
Set SourceFolder = FSO.GetFolder(configsourcepath)
Set DestinationFolder = FSO.GetFolder(configdestpath)
else
userreply = msgbox("Unable to find the selected wallpaper directory. Would you like to change" _
& " your wallpaper changer settings now?", vbYesNo)
if (userreply = 6) then
' If user agrees, call the configuration script to modify settings.
ModifyConfigurationSettingsFile
' Quit this script (will be re-run if/when user modifies configuration settings file).
WScript.Quit
end if
end if
'-------------------------
' DEBUGGING: Notify user that wallpaper directory is valid
' WScript.Echo "SourceDirectory is valid!" & chr(13) & configsourcepath & chr(13) & "DestinationDirectory is valid!" & chr(13) & configdestpath
'-------------------------
'-------------------------
' Set the default folder for source images (in case there are no override folders or override folders are empty
'-------------------------
Set SourceFolder = FSO.GetFolder(configsourcepath)
folderPath = configsourcepath
'-------------------------
' Set a ((1-({min/max}))*100)% chance that the program will check for special "override" folder for a particular month or a particular date range
' If min=1 and max=4, you have a 75% probability that the program will check for the "override" folder instead of the default folder
' If max=1000, you have a nearly 100% probability that the program will ONLY look in the "override" folder and NEVER in the default folder
'
'-------------------------
max = 1000
min = 1
Randomize
therand = Int((max-min+1) * Rnd+min)
if (therand<max) then
' If a folder exists for a specific month...
if (objFSO.FolderExists(configsourcepath & "\" & mo)) then
' If no images in this folder, use the default folder
Set temp = FSO.GetFolder(configsourcepath & "\" & mo)
if (temp.Files.Count > 0) then
Set SourceFolder = FSO.GetFolder(configsourcepath & "\" & mo)
folderPath = configsourcepath & "\" & mo
moday = mo
end if
end if
' If a folder exists for a specific date range...
Set objFolder = objFSO.GetFolder(configsourcepath)
Set colSubfolders = objFolder.Subfolders
For Each objSubfolder in colSubfolders
if (instr(1,objSubfolder.Name,"-") > 0) then
sdate = left(objSubfolder.Name, instr(1, objSubfolder.Name,"-")-1)
edate = right(objSubfolder.Name, InstrRev(objSubfolder.Name, "-")-1)
if ((mo & "_" & da) >= sdate AND (mo & "_" & da) <= edate) then
' If no images in this folder, use the default folder
Set temp = FSO.GetFolder(configcontents(1) & "\" & objSubfolder.Name)
if (temp.Files.Count > 0) then
Set SourceFolder = FSO.GetFolder(configcontents(1) & "\" & objSubfolder.Name)
folderPath = configcontents(1) & "\" & objSubfolder.Name
moday = objSubfolder.Name
end if
else
'-------------------------
' DEBUGGING: Show the dates calculated
' WScript.Echo "mo_da = " & mo & "_" & da & chr(13) & "sdate = " & sdate
'-------------------------
end if
end if
Next
end if
'-------------------------
' If a folder exists and contains images for a specific day, ALWAYS use that folder
'-------------------------
if (objFSO.FolderExists(configsourcepath & "\" & mo & "_" & da)) then
' If no images in this folder, use the default folder
Set temp = FSO.GetFolder(configsourcepath & "\" & mo & "_" & da)
if (temp.Files.Count > 0) then
Set SourceFolder = FSO.GetFolder(configsourcepath & "\" & mo & "_" & da)
folderPath = configcontents(1) & "\" & mo & "_" & da
moday = mo & "_" & da
end if
end if
'-------------------------
' DEBUGGING: Tell user folder exists for this month
' WScript.Echo "You are using the following folder: " & SourceFolder.Path
'-------------------------
'-------------------------
' Select a random picture to use for the wallpaper
'-------------------------
max = SourceFolder.Files.Count
min = 1
Randomize
therand = Int((max-min+1) * Rnd+min)
temp = ""
i = 0
' configkeepimages_orig = configkeepimages
if (max<CInt(configkeepimages)) then
' WScript.echo "Changing max number of images from " & CInt(configkeepimages) & " to " & max
configkeepimages = max
' If you want to keep 20 files in your destination folder, but only have 2 in your source folder,
' this sets you up to only keep as many files as are available.
' If you have only a few available files to choose from, this script
' will make multiple copies of them and add them to the destination
' folder. With this configuration check, it prevents the system from
' making excessive copies of your images.
end if
' Select a file with qualifying extension
For each file in SourceFolder.Files
i = i+1
extName = right(file.Name, 3)
if (extName="jpg" OR extName="JPG" OR extName="bmp" OR extName="BMP" OR extName="gif" OR extName="GIF" OR extName="png" OR extName="PNG") then
' Get first file as default file
if (temp="") then
temp = file.Name
defFile = file.Name
end if
if (i=therand) then
temp = file.Name
end if
else
if (i=therand) then
min=i+1
Randomize
therand = Int((max-min+1)*Rnd+min)
end if
end if
Next
if (temp="") then
SelectNewWallpaper = defFile
else
SelectNewWallpaper = temp
end if
'WScript.echo "You have chosen: " &chr(13) & selectedwallpaper
else
'-------------------------
' If no configuration file has been found, but this subroutine has been called...exit application
'-------------------------
WScript.Quit
' Application has failed.
end if
'-------------------------END OF SELECT NEW WALLPAPER FUNCTION-------------------------
End Function
Function CopyNewWallpaper()
' This function changes the registry settings to select the new wallpaper and other user preferences from the
' configuration settings file.
On Error Resume Next
Err.Clear
if (isnull(selectedwallpaper) OR selectedwallpaper = "") then
msgbox("No wallpaper found in " & folderPath & "\" & selectedwallpaper)
else
Set DestFolder = FSO.GetFolder(configdestpath)
' Check to see if this image is already in the destiantion folder. If so, select a new image
j = 1
While (j<(CInt(configkeepimages)+1))
'WScript.echo "Checking for duplicates of " & selectedwallpaper & "." & chr(13) & "Iteration " & j & "."
For each file in DestFolder.Files
temp1 = right(file.Name,len(file.Name)-instr(file.Name,"-"))
if ((lcase(temp1)=lcase(selectedwallpaper) OR lcase(right(temp1,len(temp1)-12))=lcase(selectedwallpaper)) AND errorcount<=CInt(configkeepimages)) then
error="Duplicate"
end if
Next
if (error="Duplicate") then
logText = logText & chr(13) & "[DUPLICATE IMAGE ] [" & timestamp & "] Found Duplicate File (" & j & ") - " & _
selectedwallpaper & ". Selecting a new wallpaper."
'WScript.Echo "Duplicate found: " & selectedwallpaper & ". Calling SelectNewWallpaper Function."
selectedwallpaper=SelectNewWallpaper
else
j=(CInt(configkeepimages)+1)
end if
error=""
j=j+1
Wend
' WScript.echo logText
' Delete old #1 wallpaper and all wallpapers over the keep limit
For each file in DestFolder.Files
temp1=CInt(left(file.Name,instr(file.Name,"-")-1))
if (temp1<1) then
temp1=1
end if
if ((temp1+1)<10 AND temp1>0) then
temp2 = "0" & (temp1+1)
else
temp2 = "" & (temp1+1)
end if
'WScript.echo file.Name & chr(13) & "Temp1="&temp1 & chr(13) & "Temp2=" & temp2
'WScript.echo temp1 & chr(13) & temp2 & chr(13) & right(file.Name,len(file.Name)-2) & _
' chr(13) & "will be moved from " & chr(13) &_
' configdestpath & "\" & file.Name & chr(13) & "to" &chr(13) &_
' configdestpath & "\" & temp2 & (right(file.Name,len(file.Name)-2))
NewFileName = temp2 & "-" & (right(file.Name,len(file.Name)-instr(file.Name,"-")))
if (objFSO.FileExists(configdestpath & "\" & NewFileName)) then
objFSO.MoveFile configdestpath & "\" & NewFileName, configdestpath & "\" & _
temp2 & "-" & timestamp & NewFileName
end if
objFSO.MoveFile configdestpath & "\" & file.Name, configdestpath & "\" & _
temp2 & "-" & (right(file.Name,len(file.Name)-instr(file.Name,"-")))
Next
For each file in DestFolder.Files
temp1=CInt(left(file.Name,instr(file.Name,"-")-1))
if (temp1<2 OR temp1>CInt(configkeepimages)) then
objFSO.DeleteFile file
end if
'if (left(temp.Name,2)
Next
' Copy new wallpaper file over to the new location
objFSO.CopyFile SourceFolder.Path & "\" & selectedwallpaper , DestFolder.Path & "\" & "01-" & selectedwallpaper
' Write the new information in the configuration file
Set objWallFile = objFSO.CreateTextFile (scriptDirectory & wallFile, ForWriting)
objWallFile.WriteLine("Get New Images From This Directory:")
objWallFile.WriteLine(configsourcepath)
objWallFile.WriteLine("")
objWallFile.WriteLine("Store Current Wallpaper Images in This Directory:")
objWallFile.WriteLine(configdestpath)
objWallFile.WriteLine("")
objWallFile.WriteLine("Keep This Number of Wallpaper Images:")
objWallFile.WriteLine(CInt(configkeepimages_orig))
objWallFile.WriteLine("")
objWallFile.WriteLine("Wallpaper Last Changed:")
objWallFile.WriteLine(Now())
' Call another function to delete older wallpapers from the destination location
end if
End Function