What's the best way to programmatically merge a .reg file into the registry? This is for unit testing; the .reg file is a test artifact which will be added then removed at the start and end of testing.
Or, if there's a better way to unit test against the registry...
It is possible to remove registry keys using a .reg file, although I'm not sure how well it's documented. Here's how:
REGEDIT4
[-HKEY_CURRENT_USER\Software\<otherpath>]
The - in front of the key name tells Regedit that you want to remove the key.
To run this silently, type:
regedit /s "myfile.reg"
If you're shelling out, I'd use the reg command (details below). If you can tell us what language you're working with, we could provide language specific code.
C:>reg /?
REG Operation [Parameter List]
Operation [ QUERY | ADD | DELETE | COPY |
SAVE | LOAD | UNLOAD | RESTORE |
COMPARE | EXPORT | IMPORT | FLAGS ]
Return Code: (Except for REG COMPARE)
0 - Successful
1 - Failed
For help on a specific operation type:
REG ADD /?
REG DELETE /?
[snipped]
I looked into it by checking out my file associations.
It seems that a .reg file is just called as the first parameter to the regedit.exe executable on Windows.
So you can just say regedit.exe "mytest.reg". What I'm not sure of is how to get rid of the dialog box that pops up that asks for your confirmation.
Use the Win32 API function ShellExecute() or ShellExecuteEx(). If the comment is 'open' it should merge the .reg file. I haven't tested it, but it should work.
One of the most frustrating things about writing unit tests is dealing with dependencies. One of the greatest things about Test-Driven Development is that it produces code that is decoupled from its dependencies. Cool, huh?
When I find myself asking questions like this one, I look for ways to decouple the code I'm writing from the dependency. Separate out the reading of the registry from the complexity that you'd like to test.
Related
Before asking this question I searched a lot about Logging (the terminal Debug Log) into a file for Tizen Application. I figured out some other ways to implement using several alternatives a bit complex pathway for this problem. But I want something straightforward, simple and builtin for Tizen Applications.
So here is what I want -
I will run a Tizen application written in C/C++. It will generate response logs on the terminal based on the several queries I ask to the app.
I want to save those logs into a specific file like file_name.log .
That file_name.log will be saved somewhere within my PC. Developer can change the location as my own.
Is there any command or an existing system for Tizen apps ?
Thank you in advance.
Read https://developer.tizen.org/development/guides/native-application/error-handling/system-logs about Tizen's built-in logging system.
As stated in the page, the logs can be also retrieved from the command line using sdb shell dlogutil [options...] [TAG], or simply sdb dlog [options...] [TAG]. So if you want to save the output as a file, simply do sdb dlog [-d] MY_APP > file_name.log. If this is not what you are searching for, please be more specific in your question.
Very new to siebel and I want to perform a repository migration from one environment to another.
The command I am using is something like this on the target serve
./srvrupgwiz /m master_Test2Prod.ucf
so my question is what happened if repo migration fails in the middle and unable to continue?
Will the target environment becomes corrupted? Is there a way to recover?
I am thinking must be a way to take a backup of the current repository on the target environment and somehow be able to restore that?
If this is true, then how to do that?
thanks
By default, the Siebel Respository you are replacing in the target environment will be renamed to "SS Temp Siebel Respository". You are prompted to supply the name for the newly imported repository (which will default to "Siebel Repository"). When a new repository row is being imported, its ROW_ID value is appended to the end of the name you provided. Once it is successfully committed, that suffixed value is removed. Therefore you can always tell when a repository is partially imported. If something fails, it's perfectly safe to delete the partial one (or leave it there, the next attempt will result in an entirely new one with yet another ROW_ID value suffixed to the end). You can recover the old one simply by renaming it. You can see the exact steps followed by the Database Configuration utility's Migrate Repository process by looking in the UCF files that drive it (e.g. master_dev2prod.ucf and driver_dev2prod.ucf).
In all fairness Siebel version and Database system have little influence on the type of solution that most will put in place: which is reversal of the database changes.
Now, Oracle, Microsoft and IBM (only supported brands) each have their own approaches and I'm more familiar with those of Oracle. Many Oracle implementations support flashback. This is a rolling log of all changes which allows one to 'travel back in time' by undoing the statements. This includes deletes as well. The maximum size of this log is one to have attention for as the Siebel DB is quite a large volume of data to be imported. I'm sure that Microsoft and IBM systems have similar technologies.
In any case the old fashioned export to disk works in all systems.
You can backup the existing repository by going to Repository object type in the object explorer and renaming the existing repository in the siebel tools.
In case the repository import fails, you just need to change the name of the backed up repository to Siebel Repository.
Also use /l log_file_name in the command to capture the logs of the import process.
Your command is fine for a migration of repository using an answer file. However, you can split out the repository migration into individual commands rather than using the unattended upgrade wizard. One of these commands is (windows):
%SIEBSRVR_HOME%\bin\repimexp.exe
You can use this executable to import or export repositories. It is often used as a means to backup existing repositories, which tends to be referred to as "exprep". Rather than spend additional time during a release doing full export from source then import into target, the export from source can be done in advance writing out to a .dat file which represents the entire repository. This file can then be read in as part of a repository import which can save time.
In order to perform an export/backup of your current repository, you can use a command like below (windows):
%SIEBSRVR_HOME%\bin\repimexp.exe /A E /U SADMIN /P PASSWORD /C ENTERPRISE_DATASOURCENAME_DSN /D SIEBEL /R "Siebel Repository" /F c:\my_export.dat /V Y /L c:\my_exprep.log
Once you have the exported .dat file, you can run a repository import referring to this file, rather than a database with your repository inside. You do this the same way using an answer file like in your original command, but the answer file will reference the .dat file. You can step through the Siebel wizard in order to write out this answer file if you are not confident editing it manually.
Ultimately, I want a way (a free way) to monitor changes in a folder and then output those changes to text file. Now this would need to be done programmatically as im using autohotkey to start the process and id like it if it was unseen by the user. I've tried copying the contents of the folder to text file before the change then after the change then using findstr to compare the two and only output the difference to text file. But, findstr outputs false positives. It would output file names as differences even though I can visually confirm they are the same in both files. I need something similar to findstr.
I need something to work like this:
file1.txt
file1.mp3
file2.mp3
file3.mp3
file2.txt
file1.mp3
file2.mp3
file3.mp3
file4.mp3
diff.txt
file4.mp3
Findstr works exactly how I need it to work except for the errors.
findstr /lv /g:file1.txt file2.txt>diff.txt
The error I speak of is with the case sensitivity on, I get 2 files in diff.txt that I know are the same in file1.txt and file2.txt. With case sensitivity off, I get like 30 0r 40 files that are the same in both.
Autohotkey has a very round-about way to accomplish this but I would much prefer a simpler way. Either batch, vbs, or anything else that will run natively on windows 7 or a standalone exe. Something relatively simple and free.
What I am trying to achieve is whatever file is added to the folder, a text file is then created, with the same file name minus the extension, and added to dropbox then IFTTT detects the file and notifies me via sms that 'filename' has finished downloading.
I finished and perfected the method of texting the download link to my pc (via a combination of AHK, batch and IFTTT) which automatically downloads the file. Now I just want a way to be notified its done.
My question is a bit related to this one but it's not what I was aiming for:
programmatically merge .reg file into win32 registry
What I want to do is to create a program that can import a .reg file using win32 or some other library. I tried looking around but failed at that part. Something like a regedit.exe /s function. Is it possible to do this without using regedit.exe or reg.exe in anyway?
So.. no system("myfile.reg") or like ShellExecute() using reg.exe or regedit.exe
Thanks!
Since regedit.exe created the reg file in the first place, I'm not really sure why you wouldn't also want it to do the import.
One other option would be to parse the reg file and then convert the parsed information into direct calls to the RegCreateKey, RegSetValue Win32 API functions, but I suspect that would be a fair amount of coding effort.
I'm working on +1M LOC C/C++ project on Solaris (remote, via VNC or SSH). I have a daily updated copy of source code on my local machine too (Windows, just for browsing code).
I use VIM and ctags combo (on both Solaris and Windows) but I'm not happy with results / speed. What settings for ctags would you recommend? There are a lot of options what should be tagged and how. Should I use single tag file per project, per dir or perhaps just one for everything?
Using anything less than one for everything doesn't really make sense to me. Being able to quickly jump around your project is what tags are for in the first place. For instance, our code is divided into 3 main sections, Include/, Processes/, Libraries/. Without being able to jump between these I would be incredibly unproductive.
Personally I use cscope (its C++ parsing isn't great, but its ok, and its VIM integration is better than just ctags), but when I do use ctags I usually just add --c++-kinds=+p.
I use etags:
find src1 src2 src3 | grep -v "\\.svn" | xargs etags --append
In emacs, position cursor on identifier and press M-. ([alt] + [period], or [esc] followed by [period]).
I don't know how it compares to your setup as far as speed goes, or if you're willing to use emacs. I'm just posting in case you want to try some alternatives.