0

I have the below code to process the move of suppression files but its moving from the desktop and not the folder in which the batch file is located.

JobNo = InputBox("Input Job Number")
strfolder = InputBox("Input the job name: ex. Monthly Statements, or Brochures")


Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Run """C:\TEST\" & JobNo & " " & strfolder & "\Processing\Suppressions.bat"""

I just thought that I could also add an echo to the batch file, but I was trying to avoid this if possible. The echo would be CD to the directory where the bat was located.

Thoughts?

Compo
  • 36,585
  • 5
  • 27
  • 39
John D
  • 139
  • 13
  • 2
    Try setting the current directory in your VBS script with `oWSH.CurrentDirectory = oFSO.GetParentFolderName(WScript.ScriptFullName)`. See [this answer](https://stackoverflow.com/a/70043076/15764378). – LesFerch May 26 '23 at 14:23
  • And please follow up on your [previous question](https://stackoverflow.com/q/76335080/15764378). Thanks. – LesFerch May 26 '23 at 14:25
  • 1
    It appears to me as if the first line of your batch file, _(`Suppressions.bat`)_, should be ```@CD /D "%~dp0"```, or ```@PushD "%~dp0"```. – Compo May 26 '23 at 15:30

1 Answers1

0

The following code, based upon the comment by LesFerch, solved my issue!

JobNo = InputBox("Input Job Number")
strfolder = InputBox("Input the job name: ex. Monthly Statements, or Brochures")

set objFSO = CreateObject("Scripting.FileSystemObject")

Set objShell = WScript.CreateObject("WScript.Shell")
objShell.CurrentDirectory = objFSO.GetParentFolderName("C:\TEST\" & JobNo & " " & strfolder & "\Processing\Suppressions.bat")
objShell.Run """C:\TEST\" & JobNo & " " & strfolder & "\Processing\Suppressions.bat"""
Compo
  • 36,585
  • 5
  • 27
  • 39
John D
  • 139
  • 13