Help converting bat file to vb script or hta

I need some help converting a bat file to vb script, hta, or something recommended. I didn't write the bat file but inherited this and my team doesn't have the skill. Unfortunately, I don't have the time to invest learning the code to do this. Would someone be willing to do this for me? Here's the bat file coding.

CLS
 P:
 :: CLIENT CODE NUMBER ENTRY
 SET /P C=TYPE 3 or 4-DIGIT CLIENT CODE NUMBER THEN PRESS ENTER:
 :: PROJECT NUMBER ENTRY
 SET /P P=TYPE 3-DIGIT PROJECT SEQUENCE NUMBER THEN PRESS ENTER:
 :: CHECK TO SEE IF THE CLIENT DIRECTORY EXISTS
 IF NOT EXIST P:\%C%\NUL GOTO NOWINDIR
 :: CHECK TO SEE OF THE PROJECT DIRECTORY EXISTS
 IF EXIST P:\%C%\130%C%%P%\NUL GOTO DIREXISTS
 IF EXIST P:\%C%\%C%%P%\NUL GOTO DIREXISTS
 GOTO MAINPROGRAM
 :NOWINDIR
 CLS
 ECHO.
 ECHO THE CLIENT DIRECTORY DOES NOT EXIST
 ECHO PRESS 1 OR 2 TO SELECT YOUR TASK
 ECHO.
 ECHO 1 - CREATE NEW CLIENT DIRECTORY
 ECHO 2 - EXIT
 ECHO.
 SET /P M=TYPE 1 OR 2, THEN PRESS ENTER:
 ECHO.
 ECHO.
 IF %M%==1, GOTO CREATE
 IF %M%==2, GOTO EOF
 :CREATE
 MD %C%
 :MAINPROGRAM
 ECHO.
 ECHO PLEASE WAIT, PREPARING TO COPY FOLDERS
 ECHO.
 IF %C%==461 GOTO CREATENGNNDIR
 ECHO.
 XCOPY P:\000\0001 P:\%C%\%C%%P% /E /Y /I
 ECHO.
 IF NOT EXIST P:\%C%\%C%%P%\NUL GOTO NOSUCCESS
 ECHO.
 ECHO THE DIRECTORIES WERE COPIED SUCCESSFULLY! NOW COPYING FILES!
 ECHO.
 XCOPY "\\server\Main\Project\Proj Documents\Proposal (Multi Discipline).docm" P:\%C%\%C%%P%\01-PM\01-ProposalBudgetEDN /v
 XCOPY "\\server\Main\Project\Proj Documents\Proposal (Single Discipline).docm" P:\%C%\%C%%P%\01-PM\01-ProposalBudgetEDN /v
 XCOPY "\\server\Main\Project\Proj Documents\Man-Hour Estimating Sheet.xlsm" P:\%C%\%C%%P%\01-PM\01-ProposalBudgetEDN /v
 XCOPY "\\server\Main\Project\Proj Documents\Scope Deviation Log.xls" P:\%C%\%C%%P%\01-PM\01-ProposalBudgetEDN\EDN /v
 ECHO.
 GOTO ERRORCHECK
 ECHO.
 :CREATENGNNDIR
 XCOPY P:\000\0001 P:\%C%\130%C%%P% /E /Y /I
 ECHO.
 IF NOT EXIST P:\%C%\130%C%%P%\NUL GOTO NOSUCCESS
 ECHO.
 ECHO THE DIRECTORIES WERE COPIED SUCCESSFULLY! NOW COPYING FILES!
 ECHO.
 XCOPY "\\server\Main\Project\Proj Documents\Proposal Template.docx" P:\%C%\130%C%%P%\01-PM\01-ProposalBudgetEDN /v
 XCOPY "\\server\Main\Project\Proj Documents\Man-Hour Estimating Sheet.xlsm" P:\%C%\130%C%%P%\01-PM\01-ProposalBudgetEDN /v
 XCOPY "\\server\Main\Project\Proj Documents\Scope Deviation Log.xls" P:\%C%\130%C%%P%\01-PM\01-ProposalBudgetEDN\EDN /v
 REN "P:\%C%\130%C%%P%\01-PM\01-ProposalBudgetEDN\Proposal NGSB Template.docx" "130%C%%P% Proposal.docx"
 REN "P:\%C%\130%C%%P%\01-PM\01-ProposalBudgetEDN\Man-Hour Estimating Sheet.xlsm" "130%C%%P% Man-Hour Estimating Sheet.xlsm"
 REN "P:\%C%\130%C%%P%\01-PM\01-ProposalBudgetEDN\EDN\Scope Deviation Log.xls" "130%C%%P% Scope Deviation Log.xls"
 ECHO.
 GOTO ERRORCHECK
 ECHO.
 :NOSUCCESS
 ECHO.
 ECHO THE DIRECTORIES WERE NOT COPIED SUCCESSFULLY!
 PAUSE
 GOTO EOF
 :DIREXISTS
 ECHO.
 ECHO THE PROJECT DIRECTORY ALREADY EXISTS
 ECHO RUN THE PROGRAM AGAIN WITH A DIFFERENT PROJECT NUMBER
 PAUSE
 GOTO EOF
 :ERRORCHECK
 IF ERRORLEVEL 0 GOTO FILECOPYOK
 ECHO THE FILES WERE NOT COPIED SUCCESSFULLY!
 PAUSE
 GOTO EOF
 :FILECOPYOK
 ECHO THE FILES WERE COPIED SUCCESSFULLY!
 PAUSE
 :EOF
 EXIT

Thanks as always.

Eddie
Eddie_1Asked:
Who is Participating?
 
QlemoConnect With a Mentor Batchelor, Developer and EE Topic AdvisorCommented:
There are several bugs in that code, and much of it is written very cumbersome and prone to typos. This is the PowerShell translation with some simplification (error checking for file copies was nonsense the way it has been implemented, so I left that out).
CLS

Set-Location P:
$Client  = Read-Host "TYPE 3 or 4-DIGIT CLIENT CODE NUMBER THEN PRESS ENTER:"
$Project = Read-Host "TYPE 3-DIGIT PROJECT SEQUENCE NUMBER THEN PRESS ENTER:"

if (!(Test-Path P:\$Client -PathType Container))
{
  CLS
  Write-Host @"

THE CLIENT DIRECTORY DOES NOT EXIST
PRESS 1 OR 2 TO SELECT YOUR TASK

1 - CREATE NEW CLIENT DIRECTORY
2 - EXIT

"@
  if ('2' -eq Read-Host "TYPE 1 OR 2, THEN PRESS ENTER:") { exit }
  md $Client
  Write-Host
  Write-Host
}
 
if ((Test-Path P:\$Client\130$Client$Project -PathType Container)
-or (Test-Path P:\$Client\$Client$Project    -PathType Container))
{
  Write-Host @"

THE PROJECT DIRECTORY ALREADY EXISTS
RUN THE PROGRAM AGAIN WITH A DIFFERENT PROJECT NUMBER
"@
  Read-Host "Press Enter to continue" | Out-Null
  return
}

Write-Host "`r`nPLEASE WAIT, PREPARING TO COPY FOLDERS`r`n"
if ($Client -ne 461)
{
  XCOPY P:\000\0001 P:\$Client\$Client$Project /E /Y /I
  if (Test-Path P:\$Client\$Client$Project -PathType Container)
  {
    Write-Host "`r`nTHE DIRECTORIES WERE COPIED SUCCESSFULLY! NOW COPYING FILES!`r`n"
    XCOPY "\\server\Main\Project\Proj Documents\Proposal (Multi Discipline).docm"  P:\$Client\$Client$Project\01-PM\01-ProposalBudgetEDN /v
    XCOPY "\\server\Main\Project\Proj Documents\Proposal (Single Discipline).docm" P:\$Client\$Client$Project\01-PM\01-ProposalBudgetEDN /v
    XCOPY "\\server\Main\Project\Proj Documents\Man-Hour Estimating Sheet.xlsm"    P:\$Client\$Client$Project\01-PM\01-ProposalBudgetEDN /v
    XCOPY "\\server\Main\Project\Proj Documents\Scope Deviation Log.xls"           P:\$Client\$Client$Project\01-PM\01-ProposalBudgetEDN\EDN /v
    Write-Host
  } else {
    Write-Host "THE DIRECTORIES WERE NOT COPIED SUCCESSFULLY!"
    Read-Host "Press Enter to continue" | Out-Null
    return
  }
} else {
  XCOPY P:\000\0001 P:\$Client\130$Client$Project /E /Y /I
  if (Test-Path P:\$Client\130$Client$Project -PathType Container)
  {
    Write-Host "`r`nTHE DIRECTORIES WERE COPIED SUCCESSFULLY! NOW COPYING FILES!`r`n"
    XCOPY "\\server\Main\Project\Proj Documents\Proposal NGSB Template.docx"    "P:\$Client\130$Client$Project\01-PM\01-ProposalBudgetEDN\Project Proposal.docx" /v
    XCOPY "\\server\Main\Project\Proj Documents\Man-Hour Estimating Sheet.xlsm" "P:\$Client\130$Client$Project\01-PM\01-ProposalBudgetEDN\130$Client$Project Man-Hour Estimating Sheet.xlsm" /v
    XCOPY "\\server\Main\Project\Proj Documents\Scope Deviation Log.xls"        "P:\$Client\130$Client$Project\01-PM\01-ProposalBudgetEDN\EDN\130$Client$Project Scope Deviation Log.xls" /v
    Write-Host
  } else {
    Write-Host "THE DIRECTORIES WERE NOT COPIED SUCCESSFULLY!"
    Read-Host "Press Enter to continue" | Out-Null
    return
  }
}

Open in new window

0
 
Eddie_1Author Commented:
This is great. Thanks Qlemo.

I've run this getting an error "You must provide a value expression on the right-hand side of the '-eq' operator". What do think? And, is there a way to direct output to a text file?
0
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
The error is in line 19, and that should be:
  if ('2' -eq (Read-Host "TYPE 1 OR 2, THEN PRESS ENTER:")) { return }

Open in new window

Of course you can write output to a file. But you need to be aware that the script is part interactive (by prompting for answers), part logging, and separate those tasks from each other.
Whenever you need to write to the screen, use write-host. Else you can use write-output "Sometext" >> logfile.txt to do so. But you will have to determine yourself which outputs are useful in a logfile ... IMHO none is, all require the user something to do immediately.
0
Improved Protection from Phishing Attacks

WatchGuard DNSWatch reduces malware infections by detecting and blocking malicious DNS requests, improving your ability to protect employees from phishing attacks. Learn more about our newest service included in Total Security Suite today!

 
Eddie_1Author Commented:
I've made the change to line 19 and am now getting "Missing closing ')' after expression in 'if' statement."

I'll leave the output alone.
0
 
Eddie_1Author Commented:
.....the error is coming from line 26, char 1.
0
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
The line as I posted last is correct. Looks like you have not copied both closing parens?
0
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
Sorry for that. There is a backtick missing at the end of line 25:
if ((Test-Path P:\$Client\130$Client$Project -PathType Container) `

Open in new window

alternatively you can join lines 25 and 26 into a single line.
0
 
Eddie_1Author Commented:
Woo, Hoo !!!!!  That's it. Thank you Qlemo.

I gladly bow to programmers performing their magic.
0
 
Eddie_1Author Commented:
Absolutely fanstically done. Big thumbs up to Qlemo. Thanks again!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.