I have then found this post https://superuser.com/questions/282963/ ... ping-it-to which turned out to be a very easy way to add UNC as pushd command automatically mounts a network drive and popd dismounts it again
As this would help others as well have I added a patch which changes all cd commands to pushd and popd command to add UNC network path support - so scripts can be easily run from a network share or local hard disc without any change or wrapper script needed.
In short what the patch does is replace in all cmds:
cd /D "%~dp0"
with:
pushd "%~dp0"
and adding popd at the end of the file before endlocal.
Would be great if this patch could be applied.
Thanks,
Oliver
phpbb doesn't allow me to attach a text file therefore here the patchs content:
- Code: Select all
From b86aa0df820aee10160477cc8e714045ae15f50c Mon Sep 17 00:00:00 2001
From: Oliver Sauder <os@esite.ch>
Date: Tue, 5 May 2015 15:26:04 +0300
Subject: [PATCH] use pushd and popd for UNC support
---
client/cmd/DoUpdate.cmd | 4 ++--
client/cmd/RecallStub.cmd | 3 ++-
cmd/DownloadUpdates.cmd | 3 ++-
cmd/IntegrateSourcesSxsFolder.cmd | 3 ++-
cmd/RemoveCustomLanguageSupport.cmd | 3 ++-
cmd/RemoveEnglishLanguageSupport.cmd | 3 ++-
cmd/RemoveGermanLanguageSupport.cmd | 3 ++-
cmd/RemoveOffice2010x64Support.cmd | 3 ++-
cmd/UpdateOU.cmd | 5 +++--
9 files changed, 19 insertions(+), 11 deletions(-)
diff --git a/client/cmd/DoUpdate.cmd b/client/cmd/DoUpdate.cmd
index 9cbb0ab..16f5fba 100644
--- a/client/cmd/DoUpdate.cmd
+++ b/client/cmd/DoUpdate.cmd
@@ -7,7 +7,7 @@ if errorlevel 1 goto NoExtensions
if "%DIRCMD%" NEQ "" set DIRCMD=
-cd /D "%~dp0"
+pushd "%~dp0"
set WSUSOFFLINE_VERSION=9.6+ (r661)
title %~n0 %*
@@ -1841,7 +1841,7 @@ if exist .\custom\FinalizationHook.cmd (
popd
echo %DATE% %TIME% - Info: Executed custom finalization hook ^(Errorlevel: %errorlevel%^)>>%UPDATE_LOGFILE%
)
-cd ..
+popd
echo Ending WSUS Offline Update at %TIME%...
echo %DATE% %TIME% - Info: Ending WSUS Offline Update>>%UPDATE_LOGFILE%
title %ComSpec%
diff --git a/client/cmd/RecallStub.cmd b/client/cmd/RecallStub.cmd
index e5dcdb6..2da3671 100644
--- a/client/cmd/RecallStub.cmd
+++ b/client/cmd/RecallStub.cmd
@@ -5,7 +5,7 @@ setlocal
if "%UPDATE_LOGFILE%"=="" set UPDATE_LOGFILE=%SystemRoot%\wsusofflineupdate.log
-cd /D "%~dp0"
+pushd "%~dp0"
if exist %UPDATE_LOGFILE% echo.>>%UPDATE_LOGFILE%
if not exist RecallUpdate.cmd (
@@ -41,4 +41,5 @@ echo Rebooting...
goto EoF
:EoF
+popd
endlocal
diff --git a/cmd/DownloadUpdates.cmd b/cmd/DownloadUpdates.cmd
index 4764ae1..74f9039 100644
--- a/cmd/DownloadUpdates.cmd
+++ b/cmd/DownloadUpdates.cmd
@@ -7,7 +7,7 @@ if errorlevel 1 goto NoExtensions
if "%DIRCMD%" NEQ "" set DIRCMD=
-cd /D "%~dp0"
+pushd "%~dp0"
set WSUSOFFLINE_VERSION=9.6+ (r661)
title %~n0 %1 %2 %3 %4 %5 %6 %7 %8 %9
@@ -1669,4 +1669,5 @@ if exist .\custom\FinalizationHook.cmd (
echo Done.
echo %DATE% %TIME% - Info: Ending WSUS Offline Update download for %1 %2>>%DOWNLOAD_LOGFILE%
title %ComSpec%
+popd
endlocal
diff --git a/cmd/IntegrateSourcesSxsFolder.cmd b/cmd/IntegrateSourcesSxsFolder.cmd
index 23907a5..df27594 100644
--- a/cmd/IntegrateSourcesSxsFolder.cmd
+++ b/cmd/IntegrateSourcesSxsFolder.cmd
@@ -5,7 +5,7 @@ verify other 2>nul
setlocal enableextensions
if errorlevel 1 goto NoExtensions
-cd /D "%~dp0"
+pushd "%~dp0"
title %~n0 %1 %2 %3 %4
set DOWNLOAD_LOGFILE=..\log\download.log
@@ -87,4 +87,5 @@ goto :eof
:EoF
title %ComSpec%
+popd
endlocal
diff --git a/cmd/RemoveCustomLanguageSupport.cmd b/cmd/RemoveCustomLanguageSupport.cmd
index eb73304..7bc52cd 100644
--- a/cmd/RemoveCustomLanguageSupport.cmd
+++ b/cmd/RemoveCustomLanguageSupport.cmd
@@ -5,7 +5,7 @@ verify other 2>nul
setlocal enableextensions
if errorlevel 1 goto NoExtensions
-cd /D "%~dp0"
+pushd "%~dp0"
for %%i in (fra esn jpn kor rus ptg ptb nld ita chs cht plk hun csy sve trk ell ara heb dan nor fin) do if /i "%1"=="%%i" goto ValidParams
goto InvalidParams
@@ -91,4 +91,5 @@ echo.
goto EoF
:EoF
+popd
endlocal
diff --git a/cmd/RemoveEnglishLanguageSupport.cmd b/cmd/RemoveEnglishLanguageSupport.cmd
index b4ac0ab..74a487d 100644
--- a/cmd/RemoveEnglishLanguageSupport.cmd
+++ b/cmd/RemoveEnglishLanguageSupport.cmd
@@ -5,7 +5,7 @@ verify other 2>nul
setlocal enableextensions
if errorlevel 1 goto NoExtensions
-cd /D "%~dp0"
+pushd "%~dp0"
rem *** Remove support for enu from static URL files ***
pushd ..\static
@@ -64,4 +64,5 @@ echo.
goto EoF
:EoF
+popd
endlocal
diff --git a/cmd/RemoveGermanLanguageSupport.cmd b/cmd/RemoveGermanLanguageSupport.cmd
index 6dbc769..cd0e5b8 100644
--- a/cmd/RemoveGermanLanguageSupport.cmd
+++ b/cmd/RemoveGermanLanguageSupport.cmd
@@ -5,7 +5,7 @@ verify other 2>nul
setlocal enableextensions
if errorlevel 1 goto NoExtensions
-cd /D "%~dp0"
+pushd "%~dp0"
rem *** Remove support for deu from static URL files ***
pushd ..\static
@@ -64,4 +64,5 @@ echo.
goto EoF
:EoF
+popd
endlocal
diff --git a/cmd/RemoveOffice2010x64Support.cmd b/cmd/RemoveOffice2010x64Support.cmd
index 752a80e..61e7653 100644
--- a/cmd/RemoveOffice2010x64Support.cmd
+++ b/cmd/RemoveOffice2010x64Support.cmd
@@ -5,7 +5,7 @@ verify other 2>nul
setlocal enableextensions
if errorlevel 1 goto NoExtensions
-cd /D "%~dp0"
+pushd "%~dp0"
for %%i in (enu fra esn jpn kor rus ptg ptb deu nld ita chs cht plk hun csy sve trk ell ara heb dan nor fin) do if /i "%1"=="%%i" goto ValidParams
goto InvalidParams
@@ -67,4 +67,5 @@ echo.
goto EoF
:EoF
+popd
endlocal
diff --git a/cmd/UpdateOU.cmd b/cmd/UpdateOU.cmd
index a7c0e75..5ad574d 100644
--- a/cmd/UpdateOU.cmd
+++ b/cmd/UpdateOU.cmd
@@ -7,7 +7,7 @@ if errorlevel 1 goto NoExtensions
if "%DIRCMD%" NEQ "" set DIRCMD=
-cd /D "%~dp0"
+pushd "%~dp0"
set DOWNLOAD_LOGFILE=..\log\download.log
if exist %DOWNLOAD_LOGFILE% (
@@ -101,7 +101,7 @@ if "%OX64_LANG%" NEQ "" (
echo %DATE% %TIME% - Info: Updated custom language additions>>%DOWNLOAD_LOGFILE%
if "%RESTART_GENERATOR%"=="1" (
echo %DATE% %TIME% - Info: Ending WSUS Offline Update self update>>%DOWNLOAD_LOGFILE%
- cd ..
+ popd
start UpdateGenerator.exe
start http://www.wsusoffline.net/donate.html
exit
@@ -159,4 +159,5 @@ goto EoF
:EoF
echo %DATE% %TIME% - Info: Ending WSUS Offline Update self update>>%DOWNLOAD_LOGFILE%
title %ComSpec%
+popd
endlocal
--
1.9.1