1

My company has a software that updates our installers on clients' servers. During the setup, a environment variable is created along with a task with the following lines:

Variable:

setx ccloud "C:\Capela\CCloud" /M

Obs.: the path used is the "install path" defined during the setup.

Task:

schtasks.exe /Create /RU SYSTEM /SC DAILY /TN CCloudUpdater /TR "cmd.exe /C C:\Capela\CCloud\ccloud-updater.bat" /ST 02:00 /F >

The bat file has the following arguments:

@echo off
cd /d "%CCLOUD%"
ccloud.exe cache -c
ccloud.exe logs -c
ccloud.exe installers -d ccloud --w
if exist "installers\ccloud\ccloud-setup.exe" (
    START /WAIT "CCloud Setup" "installers\ccloud\ccloud-setup.exe" /S
)
ccloud.exe auto -t -i -s
timeout 60 > nul
ccloud.exe auto -t -i -s
timeout 900 > nul
ccloud.exe auto -t -i -s

After running it, our softwares and services are downloaded and extracted to a folder. The packages are defined by an online manager.

However, there is ONE server (2k8R2, just like many others) that just can't read the variable, no matter what we do. The task runs as intended, but since the variable is somehow unavailable, it can't download the packages.

We tried using

echo "%ccloud%" > path.txt

inside the bat, the TXT returns only "" like that variable is undefined.

We don't know what else to do. Can anyone help me find out what's happening?

4
  • Does the server got a antivirus which block macro/script ? Please check your AV log. I used to have such difficulty with mcafee in the past, as it blocked the script to create variable.
    – yagmoth555
    May 7, 2019 at 17:39
  • Do you really need the environment variable? Since the batch file itself is in the same folder that the environment variable points to, cd /d %~dpn0 should work. May 8, 2019 at 7:33
  • The setx command doesn't work reliably, by the way. Not sure from your description whether or not that might be your problem, but FYI. May 8, 2019 at 7:37
  • @HarryJohnston I just saw how to use %~dp0 and it should work, but we actually use the e.v for easy access to that folder. Not essential, but useful. Anyway, thank you for this! May 8, 2019 at 12:37

1 Answer 1

0

A simple restart solved the problem. Apparently the OS didn't fully mapped it during setup, although it was recognized when manually calling from CMD.

We don't know why it worked on other servers without restarting, though.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.