Reputation: 11
I have a batch file with two reg add commands in it. Both seem to work but one will show in the registry for about 5 seconds and then disappears. I have tried all the formatting styles and cannot get the one to stick. Here are the two reg adds I'm using:
reg add HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v CrashPlanTray /t REG_SZ /d C:\Users\%USERNAME%\AppData\Local\Programs\CrashPlan\electron\CrashPlanDesktop.exe --menubar --desktop=false --user.install
and
reg add HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v CrashPlanServiceUser /t REG_SZ /d C:\Users\%USERNAME%\AppData\Local\Programs\CrashPlan\CrashPlanService.vbs
It is the first one CrashPlanTray that will not stick.
I have tried it adding the \
before the data value and at the end of the data value. It will add it to the registry but then after a few seconds it disappers.
reg add HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v CrashPlanTray /t REG_SZ /d "\"C:\Users\%USERNAME%\AppData\Local\Programs\CrashPlan\electron\CrashPlanDesktop.exe\" --menubar --desktop=false --user.install
I have been trouble shooting and working with this for days now. I can get it to work and stick from a command window but once I put it in the batch file it no longer sticks. I could use some expert help in figuring out why it won't stick in the registry?
Upvotes: 1
Views: 1337
Reputation: 11
I don't know exactly what has changed but after completely uninstalling and reinstalling CrashPlan, all is working again. I can now run the batch files to disable and re-enable it they are now working correctly. Your efforts were not wasted as I am using snippets of the things you suggested in my revised batch files and it makes them much cleaner to read and work with. Thank you for your help and patience.
Upvotes: 0
Reputation:
On the first reg add, try this:
reg add HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v CrashPlanTray /t REG_SZ /d "\"%localappdata%\Programs\CrashPlan\electron\CrashPlanDesktop.exe\" --menubar --desktop=false --user.install"
Take special note of the double quotes (beginning and end) enclosing the full string to registry, as well as the escaped ones enclosing the path ( I shortened the above path for demonstration purpose:
"\"%localappdata%\..\CrashPlanDesktop.exe\" --menubar --desktop=false --user.install"
Finally, also notice we can use %localappdata%
instead of C:\users\%username%\..
Upvotes: 1
Reputation: 38579
First thing I'd do is because the locations use environment variables is to use REG_EXPAND_SZ
, instead of REG_SZ
.
I'd use backslashes to then escape any internal doublequotes and protect the locations, as they could contain things like spaces.
I'd set the common strings as values at the top to make it easier to modify and shorten the lines somewhat, and would also probably use carets, ^
to shorten the lines still further for readability.
Finally, if you're wanting to run a VBScript
from the registry run key, you should really be running it from either WScript.exe
or CScript.exe
. My example below uses WSCript
, but you can replace that with CScript
and any required options as needed.
@Set "Key=HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run"
@Set "Loc=%%LocalAppData%%\Programs\CrashPlan"
@Reg Add "%Key%" /V "CrashPlanTray" /T REG_EXPAND_SZ /D^
"\"%Loc%\electron\CrashPlanDesktop.exe\" --menubar --desktop=false --user.install" /F>Nul
@Reg Add "%Key%" /V "CrashPlanServiceUser" /T REG_EXPAND_SZ /D^
"WScript \"%Loc%\CrashPlanService.vbs\"" /F>Nul
Upvotes: 0