How run Update.cmd from "\\example.com\wsus"

How run Update.cmd from "\\example.com\wsus"

Postby luisop » 07.02.2018, 21:36

Hello community I am trying to automatically run the updates by the cmd, I have the repository in a shared folder and when executing a file "update.bat" it gives me error. The script is the following.

Call Update.cmd / updatecpp / instdotnet35 / instmsse

Thanks for your help
luisop
 
Posts: 7
Joined: 12.01.2018, 15:44

Re: How run Update.cmd from "\\example.com\wsus"

Postby Dalai » 07.02.2018, 22:49

luisop wrote:[..] and when executing a file "update.bat" it gives me error.

What error exactly?

The script is the following.

Call Update.cmd / updatecpp / instdotnet35 / instmsse

Do you really have a space after each slash? If so, that's not right. Try something like this
Code: Select all
Call "%~dp0Update.cmd" /updatecpp /instdotnet35 /instmsse
provided you update.bat is in the same directory as Update.cmd.

Regards
Dalai
Dalai
 
Posts: 628
Joined: 12.07.2016, 22:00

Re: How run Update.cmd from "\\example.com\wsus"

Postby luisop » 07.02.2018, 23:27

the problem is that it is in a network location (shared folder) "\\example.com\wsus" and when I try to execute the script it tells me that CMD is not compatible with the UNC routes.
Call \\example.com\wsus\Update.cmd / updatecpp / instdotnet35 / instmsse
luisop
 
Posts: 7
Joined: 12.01.2018, 15:44

Re: How run Update.cmd from "\\example.com\wsus"

Postby aker » 07.02.2018, 23:59

I'd recomend you to mount the UNC-path to a network drive using the same program/script calling DoUpdate.cmd.
Code: Select all
net use W: \\example.com\wsus /persistent:no
...
net use W: /delete
Last edited by Dalai on 08.02.2018, 00:39, edited 1 time in total.
Reason: Fixed a small typo in the "net use" switch
Wer Rechtschreibfehler findet, darf sie behalten oder an den Meistbietenden versteigern. / Everybody finding a misspelling is allowed to sell it.
aker
aker
 
Posts: 3045
Joined: 02.03.2011, 16:32
Location: /dev/kmem

Re: How run Update.cmd from "\\example.com\wsus"

Postby Dalai » 08.02.2018, 00:41

luisop wrote:the problem is that it is in a network location (shared folder) "\\example.com\wsus" and when I try to execute the script it tells me that CMD is not compatible with the UNC routes.

That's not a problem when you use the command I posted. But the second one you posted should work as well:
Call \\example.com\wsus\Update.cmd / updatecpp / instdotnet35 / instmsse


However, I second aker's suggestion to map the network share to a drive letter and use the letter in subsequent calls. This avoids similar issues that might occur within DoUpdate.cmd or other WSUS Offline scripts.

Regards
Dalai
Dalai
 
Posts: 628
Joined: 12.07.2016, 22:00

Re: How run Update.cmd from "\\example.com\wsus"

Postby aker » 08.02.2018, 03:59

@Dalai
UNC-Support for cmd was added somewhere in the Windows 10 area (at least as far as I know). Older OSes such as Windows 7 don't support directly calling scripts on UNC-paths.
Wer Rechtschreibfehler findet, darf sie behalten oder an den Meistbietenden versteigern. / Everybody finding a misspelling is allowed to sell it.
aker
aker
 
Posts: 3045
Joined: 02.03.2011, 16:32
Location: /dev/kmem

Re: How run Update.cmd from "\\example.com\wsus"

Postby Dalai » 08.02.2018, 05:01

aker wrote:UNC-Support for cmd was added somewhere in the Windows 10 area (at least as far as I know). Older OSes such as Windows 7 don't support directly calling scripts on UNC-paths.

I've been calling batch scripts on UNC paths since Windows 2000. What doesn't work, is setting the working directory when a batch script is called from a UNC path - doing that leads to the "error" message luisop mentioned.

Test case. Batch scripts like these two:
Code: Select all
@echo off
call \\server\share\test.cmd
Code: Select all
@echo off
echo this is a test
pause
where the first one is located on a local drive. When executed, I get the message "this is a test" just fine. Even if I move the first script to the share itself, I get the message. Modifying the first script to something like
Code: Select all
@echo off
call %~dp0test.cmd
and executing it directly from the share also shows this message, it's only preceded by the "error" message:
Code: Select all
CMD.EXE wurde mit dem oben angegebenen Pfad als aktuellem Verzeichnis gestartet.
UNC-Pfade werden nicht unterstützt.
Stattdessen wird das Windows-Verzeichnis als aktuelles Verzeichnis gesetzt.
Actually it's not an error message, just a warning that the working directory is set to the Windows directory, that's all.

In short: I'm not sure if you mean something else. One thing I do know for sure: %~dp0 also works in Windows 2000 with UNC paths, hence my suggestion above. However, I guess that the current implementation of client\Update.cmd may break my suggestion as well, because Update.cmd tries to CD to client\cmd directory (which fails with UNC paths) and then tries to start DoUpdate.cmd without specifying its path. A better implementation of Update.cmd would be (and I think I posted something similar a while ago):
Code: Select all
@echo off
cd /D "%~dp0cmd"
start "" "%~dp0cmd\DoUpdate.cmd" %*
Also a pushd/popd combination instead of a CD would work (pushd automatically maps network shares when required). The important thing is to specify absolute paths wherever possible to avoid ambiguities (or even calling the wrong script/program).

Regards
Dalai
Dalai
 
Posts: 628
Joined: 12.07.2016, 22:00

Re: How run Update.cmd from "\\example.com\wsus"

Postby luisop » 08.02.2018, 14:55

already solve the problem, thanks to everyone for the help provided.
luisop
 
Posts: 7
Joined: 12.01.2018, 15:44


Return to Installation / Updating

Who is online

Users browsing this forum: No registered users and 12 guests