0

Windows should run a script on startup that starts a DB based on an environment variable %SAPSYSTEMNAME%:

net start SYBSQL_%SAPSYSTEMNAME%

When i run this command in my cmd it works fine, however on windows startup it will be ignored somehow and the db is not started.

I entered the script in gpedit.msc under Startup scripts.

Why is this so? timeout 120 also did not help - is there an alternative?

4
  • Is %SAPSYSTEMNAME% a user or system variable? It might not be available during startup because the userprofile with its variables didn't start yet. Commented Mar 31, 2022 at 14:21
  • @RicardoBohner yes the %SAPSYSTEMNAME% is a system variable. I also tried a simple echo %SAPSYSTEMNAME% > c:\out.txt but only the file is created without content, thus the variable cannot be read i assume.
    – Core_Dev
    Commented Mar 31, 2022 at 14:26
  • Also do note that it may not be able to start the service because it is dependend on another service that must be started first. To make sure its a variable thing, test it with a hardcoded name and see if it starts at all. You know, as a test.
    – LPChip
    Commented Mar 31, 2022 at 14:44
  • @LPChip i tried to print out only the variable in a simple text file. It did not give any result, thus it guess its not based on the service order.
    – Core_Dev
    Commented Apr 1, 2022 at 7:27

1 Answer 1

1

If you REALLY want to use the variable, my solution is silly but should work.

Go STRAIGHT TO THE KEY!! :)

if "%SAPSYSTEMNAME%"=="" for /f "tokens=3" %%v in ('reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /V SAPSYSTEMNAME') do Set SAPSYSTEMNAME=%%v

Place that line before net start SYBSQL_%SAPSYSTEMNAME%

Ugly as heck but should do the trick.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .