Need Help With File Paths in Batch FIle

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
wudevr
Posts: 1
Joined: 26 Nov 2015 12:19

Need Help With File Paths in Batch FIle

#1 Post by wudevr » 26 Nov 2015 12:45

I have a batch file that copies (overwrites) a couple of files in a directory.
Currently, the file path of the source files is hard coded (C:\test)
I would like to update the batch file so that the path doesn't have to be C:\test. Ideally as long as the files are located in the same folder as the batch file, the batch file would work.
So then the batch file could be run from any folder and work, not just c:\test.
I hope I've explained myself well enough...

Here's the batch file:
-----------------------------------------------------------------------------------------------------------------------------------------------

Code: Select all

net stop sms_site_component_manager


takeown /f C:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe.config
icacls C:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe.config /grant:r "everyone:f"


xcopy C:\test\InstallUtil.exe.config C:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe.config /R /Y

xcopy C:\test\regsvcs.exe.config C:\Windows\Microsoft.NET\Framework64\v4.0.30319\regsvcs.exe.config /R /Y

icacls C:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe.config /remove:g "everyone"

sc config msdtc start= auto
net start msdtc

net start sms_site_component_manager

net stop msdtc
sc config msdtc start= disabled

---------------------------------------------------------------------------------

Thanks in advance for your help!
Last edited by wudevr on 26 Nov 2015 15:44, edited 2 times in total.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Need Help With File Paths in Batch FIle

#2 Post by foxidrive » 26 Nov 2015 13:44

If that's your code - then it doesn't work, right?

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: Need Help With File Paths in Batch FIle

#3 Post by Squashman » 26 Nov 2015 15:40

The path to the batch file is %~dp0

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Need Help With File Paths in Batch FIle

#4 Post by foxidrive » 26 Nov 2015 19:07

foxidrive wrote:If that's your code - then it doesn't work, right?

I see you changed the code that you said was your batch file, and didn't reply.

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: Need Help With File Paths in Batch FIle

#5 Post by Squashman » 26 Nov 2015 23:20

foxidrive wrote:
foxidrive wrote:If that's your code - then it doesn't work, right?

I see you changed the code that you said was your batch file, and didn't reply.

Yes. I had to re-approve the change.

Post Reply