Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5975317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:04:04+00:00 2026-05-22T21:04:04+00:00

I need to write a script that looks in a directory, finds the latest

  • 0

I need to write a script that looks in a directory, finds the latest .zip file (there are .zip and .log in there) then opens a command prompt in a different directory and runs the following command:

loaddb.bat -Dlc.file="C:\Program Files\XyEnterprise\SDL LiveContent\data_old\export\<name of the newest file.zip>" -Dlc.pswd=<oor password> RESTORE

We can not install any languages so it has to be able to run on a Windows 2003 & 2008 server so I chose vbscript…

I have everything working apart from the running the command and can’t seem to crack it.

My code is as follows:

Dim fileNewest
Dim fso
Set fso = WScript.CreateObject("Scripting.FileSystemObject")
Set oFolder = fso.GetFolder("C:\Program Files\XyEnterprise\SDL LiveContent\data\export")

For Each aFile In oFolder.Files
sExtension = fso.GetExtensionName(aFile.Name)
    If sExtension = "log" Then
            'Msgbox "The file extension is a " & sExtension
        Else
            'Msgbox "The file extension is a " & sExtension
                         If fileNewest = "" Then
                        Set fileNewest = aFile  
                     Else
                     If fileNewest.DateCreated < aFile.DateCreated Then
                            Set fileNewest = aFile
                     End If
                    End If
                End If
Next
Msgbox "The Newest File in the folder is " & fileNewest.Name & chr(13) & "Size: " & fileNewest.Size & " bytes" & chr(13) & "Was last modified on " & FileNewest.DateLastModified 

Dim objShell
Set objShell = CreateObject("WScript.Shell")
objShell.Run "%comspec% /k c: & cd ../../../Program Files\XyEnterprise\SDL LiveContent\data\export"

How can I now run a command after opening that Dos prompt?

Thanks,

EDIT:

Adding the answer worked with a lot of help from Alex K:

objShell.Run "%comspec% /k c: & cd ""C:\Program Files (x86)\XyEnterprise\SDL LiveContent\"" & """"loaddb RESTORE -Dlc.file=C:\PROGRA~2\XYENTE~1\SDLLIV~1\data\Import\" & fileNewest.Name & " -Dlc.pswd=N2kAs72z"""""
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T21:04:05+00:00Added an answer on May 22, 2026 at 9:04 pm

    You need to quote that path as it contains spaces;

    objShell.Run "%comspec% /k c: & cd ""../../../Program Files\XyEnterprise\SDL LiveContent\data\export"""
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write a bash script that looks at a directory full of
I need to write a bash script that scans directories in current directory and
I need to write a script that incrementally keeps track of files and directories
I need to write a python script that makes multiple HTTP requests to the
I need to write a Perl script that pipes input into a Java program.
I need to write a script for MS Exchange Server 2003 that will analyze
I need to write an array that looks like this: $years = array('12', '11',
I'm currently trying to write a simple script that looks in a folder, and
I need to write a bash script that will take a grepable nmap output
I need to write a script which will post username and password onto a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.