Run batch file another location

Hi I want to install DLP to my system so i created a fixlet for that i need to run a Batch file.
It has content for msiexec /i command and couple of files needs to copy when i run command.
This batch file needs to run with admin rights where the batch file located.

So when i created fixlet it automatically created this command.
"wait “{pathname of system folder & “\cmd.exe”}” /c “{(pathname of client folder of current site) & “__Download\install_agent.bat”}”

As i understand it is trying to install file under system32 folder with correct priviliages
But i want to change directory to where batch file located which is download folder in here.
Because batch file only installing application when cmd location same as the file otherwise it is not installing

`

That should not be the case, you can run any file from anywhere with full path of the installer or executable.

however if you still wants to do that you can use below format to do that-

//move batch file
move "__Download\install_agent.bat" "C:\Windows\temp\install_agent.bat"

//run batch file
waithidden cmd.exe /C C:\Windows\temp\install_agent.bat

Thanks for your reply Vijay.
Normally you are right it has to work anywhere as you said but i think it is application related. Because when i want to call batch file different directory it is not working.Also it needs a couple of files on same directory.

Before your answer i created an action script like that and it worked. Do you have any recommendation for this steps.

action uses wow64 redirection false
folder create "C:\Source"
wait xcopy “__Download\install_agent.bat” "C:\Source"
wait xcopy “__Download\1.msi” "C:\Source"
wait xcopy “__Download\xx.pem” "C:\Source"
wait xcopy “__Download\xx.pem” "C:\Source"
wait xcopy “__Download\xx.pem” "C:\Source"
wait cmd.exe /c “cd /d c:\source && install_agent.bat”

why multiple steps, just wrap your all files in one folder & than upload it. While extract give the path of desired folder no need to folder create.

prefetch ...yourfolder.tmp
extract sha1 "C:\Source" all files will be extracted directly here, no need to move.

and …
wait cmd.exe /c c:\source\install_agent.bat

2 Likes

There’s a pretty typical pattern to this. If you are writing the batch file on-they-fly you could reference the fully-qualified path to your downloads folder.

Otherwise, rather than moving your downloaded files to a temporary location, you could ‘cd’ into the downloads folder itself.

wait cmd.exe /c "cd  __Download & .\install_agent.bat"
1 Like

Thanks for you all replys it helped me very much