[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 786
  • Last Modified:

changing directory in bat file

I am working on creating a bat file/script
what i need to do at the end of the file is change to another directory.
Current code:

suggestions on how I can get this to work....currently the result is to stay in the
cd "d:\test\..\Java\jasperserver-ce-3.7.0\scripts"
directory
@echo off
@echo off
cScript.exe //B //Nologo "d:\test\Shared\WriteMUSLog.vbs" "d:\test" JasperServer.bat "jsUnzip.bat [Start]"

if exist "\java\jasperreports-server-cp-4.0.0" exit

cScript.exe //B //Nologo "d:\test\Shared\WriteMUSLog.vbs" "d:\test" JasperServer.bat "jsExport.bat [Start]"

echo Exporting Repository to D:\test\JasperServer\Repository_updated (users, connections, a test report, etc.)  Please wait...

cScript.exe //B //Nologo "d:\test\Shared\WriteMUSLog.vbs" "d:\test" JasperServer.bat "exporting Jasper Repository"

cd "d:\test\..\Java\jasperserver-ce-3.7.0\scripts"
js-export --everything  --output-dir D:\test\JasperServer\Repository_updated >> "d:\test\Logs\Installation\JasperServer.log" 2>&1

CHDIR "d:\test"

Open in new window

0
Tagom
Asked:
Tagom
1 Solution
 
OrenRozenCommented:
I do not completely understand at what folder you'd like to end with.
d:\test OR d:\test\..\Java\jasperserver-ce-3.7.0\scripts

another thing, in your command you use .. in the path. that means go 1 folder down.
so basically if I'm in the folder (for example) d:\test and I type cd d:\..\test, I'll stay in the same folder.

Thanks
0
 
CrowaXCommented:
How about just putting "CD\" to take yourself back to D:. then "CD TEST" to go into the test directory?
0
 
oBdACommented:
If your script is started from any drive other than D:, any "cd D:\..." will not work as you expect it to; I suspect that the "cd" in line 13 isn't working, either.
You can either use complete paths (recommended), or always use "cd /d" which will change the directory as well as the drive:
cd /d "d:\test\..\Java\jasperserver-ce-3.7.0\scripts"
js-export --everything  --output-dir D:\test\JasperServer\Repository_updated >> "d:\test\Logs\Installation\JasperServer.log" 2>&1
CHDIR /d "d:\test"

Open in new window

0
 
Bill PrewCommented:
What I'm hearing is that after executing:

cd "d:\test\..\Java\jasperserver-ce-3.7.0\scripts"
js-export --everything  --output-dir D:\test\JasperServer\Repository_updated >> "d:\test\Logs\Installation\JasperServer.log" 2>&1
CHDIR "d:\test"

Open in new window

You are in the "d:\test" directory as the default.  This makes me thing the final CD never got executed, and this would typicall happen if the js-export didn't return control to the calling batch file.  I suspect that js-export is implemented as a BAT file, which would indeed cause this problem.  Give the following a try and see if it works better.

cd "d:\test\..\Java\jasperserver-ce-3.7.0\scripts"
call js-export --everything  --output-dir D:\test\JasperServer\Repository_updated >> "d:\test\Logs\Installation\JasperServer.log" 2>&1
CHDIR "d:\test"

Open in new window

~bp
0
 
TagomAuthor Commented:
perfect thanks
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now