using NSIS to install and run every time - jenkins

Im doing a little research into installers, and right now at my company we are having some issues deploying from jenkins using click once. We have a test certificate(these programs are all internal) and for some reason are having some issues with the certifcate being incompatiable with certain msbuilds/.net frameworks. So im looking into alternatives.
But in that i want to keep the same architecture. How it works right now is someone clicks on a button in our task bar, clicks on the application they want, and then click once installs the updates(or installs) without further user input and starts the application. Ive heard a lot of good things about NSIS.
So far ive only seen generic application installers like you expect when you download anything from the internet. Could I do something like i described above using NSIS?

A very basic no interaction installer might look like this:
Name foo
OutFile foo_setup.exe
AutoCloseWindow true
RequestExecutionLevel user
InstallDir "$LocalAppData\Programs\MyApp"
Page InstFiles
Section
SetOutPath "$InstDir"
WriteUninstaller "$InstDir\uninst.exe"
; TODO: Add registry entry for Add/Remove Programs
File "MyApp.exe"
File "Data.xml" ; Support files etc
Exec '"$InstDir\MyApp.exe" -firstrun "c:\some path\file.ext"'
SectionEnd
Section Uninstall
Delete "$InstDir\MyApp.exe"
Delete "$InstDir\Data.xml"
Delete "$InstDir\uninst.exe"
RMDir "$InstDir"
SectionEnd
If you want to install for all users in %ProgramFiles% you can run into issues with Exec because the app can end up running as the wrong user if a non-administrator used some other account in the UAC dialog.

Related

Granting "Local System" permissions the installation folder in Advanced Installer

I have an "Advanced Installer" project that I am trying to use to install my "TopShelf" windows service that I have built.
I found the spot in Advanced Installer to grant permissions to the installation folder, but I don't see a way to grant permissions to the "Local System" account.
Manually, this is done by going to the security option in the properties of the folder and adding a user with the same name as the computer name but ending with a $. For Example MyNiceComputer$. (Oh, and you have to select the "Computers" option in the types area.)
But there is no way to do all this in Advanced Installer. If I do make one like MyNiceComputer$, it just makes an empty entry in the security tab. (No Permissions on it, even though I setup for full control.)
Has anyone ever needed to do this with Advanced Installer?
Additional Details:
I am installing an app that runs as a windows service. (It is a console app built with TopShelf).
Our company policy is to install all our applications into a folder that looks like this:
C:\OurCompanyApps\MyApp
When I create the installer, it runs fine, but then I when I start up the Windows Service, I get the following error:
Windows could not start the MyApp service on Local Computer
Error 5: Access is denied.
But when I grant access to Local System (by giving Full Control rights to myNiceComputer$ on the MyApp folder), then this error goes away and the app runs fine. From what I read, this is because the application is running as Local System.
It seems odd that it needs full control but it does not work without it. (But as far as I can see, the contents of the folder are un-altered).
#Bogdan Mitrache seems to indicate that granting permissions to Local System is not possible via Advanced Installer. This is good to know (so I don't waste more time looking). I will probably ask my System Admins for a dedicated system account to run my service as. Not ideal, but it will serve as a work around.
So, in one of my "less finer" moments of debugging, I mixed up two different things.
There was also a file missing, (my config file). I restored that and changed the permissions at the same time. But then I forgot to go back and verify which one was the actual fix. (I know, not good debugging.)
So, the Access is denied error was due to a missing file.

Windows 10 - Username with whitespace and PATH [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
Upon installing Windows 10 I created my admin user as Miha Šušteršič. Now when I install programs that need to modify the environment variable PATH, most of them don't get added. For instance this happens with MongoDB and Git, but npm got added normally.
I think this is an issue with the whitespace in the path to the variables. I tried renaming my username to M.Sustersic, but the system folder Users\Miha Šušteršič\ did not get updated.
Is there a way for me to change this folder name automatically (so the rest of the app dependencies on \Users\Miha Šušteršič\AppData don't get bugged) or do I need to reinstall windows?
Is there something else I am missing here? I tried adding the dependencies on my own, but nothing worked so far.
You can actually change the folder name. It's a bit tedious but it's worth it. Make sure you know of the edition of your Windows 10 you're using first - Professional, Enterprise or Home - before carrying out these steps, cos of step 5:
Right click on Windows Start Menu option and click Command Prompt (Admin)
(If you can't find Command Prompt (Admin) when you right-click on the Start Menu or search for it, you can simply go to C:/Users/Default/AppData/Local/Microsoft/Windows/WinX/Group3 on your pc. There, you'll find two shortcuts both named "Command Prompt"; one is for Command Prompt, and the other is for Command Prompt (Admin).Try out both shortcuts to know which is which, and then click on the one for Command Prompt (Admin))
In the Command Prompt (Admin), create a new/temporary admin account by entering this command: net user Administrator /active:yes (Notice the space between Administrator and /) and close the cmd
Next, click on the start menu and sign out of your current admin account
(four icons above the shut down button)
Sign in with the new Administrator account you just created
(Skip this step only if you use the Windows Home Edition) Right click on the Start Menu and click Computer Management and open Local Users and Groups > Users. Right-click on the username you wish to change and select Rename and close the window.
Open Local Disk (C) > Users and right-click and rename the corresponding folder with the name you wish, just as in Step 5, and close the window.
Next, search for regedit in the search box and click on it. Now, inside the regedit (i.e. Registry Editor), go to HKEY_LOCAL_MACHINE > SOFTWARE > Microsoft > Windows NT > Current Version > Profile List.
In the list of identifiers under Profile List, find the ProfileImagePath that corresponds to the account name you wish to change. Yours should look something like this:
ProfileImagePath REG_EXPAND_SZ c:\Users\Miha Šušteršič.
Double click on the value and rename it to what you want.
Still in the regedit, scroll up to the top of the window and make sure the highlight is on Computer, then click Edit in the menu options just above it; then click Find; then enter C:\Users\<your old username>. In your case, that would be:
C:\Users\Miha Šušteršič
And search.
If the search brings out any result (i.e. any folder bearing your old account user name,) click on it and rename it, and then go back to Edit in the menu option and this time, click Find Next or f3. Keep on "Finding Next" this until there are no files are left to rename, then close regedit.
Finally, sign out of your Administrator account and sign in with your now-renamed account, and then, go on to disable the Administrator account you just signed out from. You do this by going to Command Prompt (Admin) and this time, you enter the command:
net user Administrator /active:no
(Once again, notice the space between Administrator and /)
...and close the command.
And that's it! Long and tedious, but it works. You can check also out this video to have a better understanding of everything I just described.
_Note: Make sure to follow every step to the letter so you don't run into more serious problems.
If you run into any issues renaming at Step 6, simply shut down your computer and restart and try again.
Also, certain files may/will not allow for renaming. It's alright; just leave them as they are and "Find Next" until there's no more file to rename._
See this KB article to change the name of the User Profile directory.
After you do this, you may want to make a link just in case any of your apps keep local path configuration.
cd C:\Users
mklink /D "Miha Šušteršič" M.Sustersic

How to backup Telegram chat?

I found somethings like this code to send to Telegram-CLI but I have no idea what it means or how to do it so if someone could explain it to me step by step I'd be so happy.
https://github.com/psamim/telegram-cli-backup
I couldn't install sqlite3 for some reason with the given code there.
I'm using windows, do I need to boot into Ubuntu to do it?
Anyways, explain it to me like I'm 3 years old in case I won't know something.
Thanks so much.
If you are using windows check the instructions here. I've only tried in Linux and the link in your question (using Lua) works.
The following scripts too does the job well
Python script to backup everything
https://github.com/tvdstaaij/telegram-json-backup
Here is a ruby version of the same https://github.com/tvdstaaij/telegram-history-dump
The mentioned script is updated and now it saves the conversations into a CSV file and does not need sqlite3 library any more. It only needs lua.
It seems I could help you a little.
I am using Ubuntu and I wrote this Bash-script:
#!/bin/bash
TOKEN='YourBot:Token'
URL='https://api.telegram.org/bot'$TOKEN
UPD_URL=$URL'/getUpdates?offset='
function get_offset {
res=$(curl $UPD_URL$OFFSET)
OFFSET=$(echo $res | grep "update_id" | cut -f 4 -d ':' | cut -f 1 -d ',' | head -1)
OFFSET=$((OFFSET+1))
}
while :
do
get_offset
if echo $res | grep "message"
then echo $res >> BackupChat.txt
fi
done
It is very simple bash-script.
Obviously you must create your own bot and add bot to the chat you want to backup.
Bad things about this script is that it creates pretty difficult for reading text logfile with mass garbage like "username" "date" "::" , etc. But it could be improved for making a normal output looking like a cool database.
I hope you have enough Linux skills to make it by yourself.
I think the situation improved since this question was asked, so here an answer from a 2020's point of view that does not require any programming skills or command line tools.
To backup (aka. "export") your Telegram chats download the desktop client available here:
https://desktop.telegram.org/
On Linux, for example, unpack the downloaded file into any subdirectory like ~/tmp/, and start the client from there, like
$ cd ~/tmp/Telegram
$ ./Telegram
You will need to register first with your phone number like on any other Telegram devices via a confirmation code sent to your already logged-in telegram account.
The user interface looks similar to the web interface.
Go into a chat you are interested in, then in the upper right menu choose "Export chat history". Click all checkboxes you are interested in, like media files, GIFs, stickers, etc. and click export.
By default it generates a complete HTML files and subdirectory structure under ~/Downloads/Telegram Desktop/ which you can open for instance like this:
firefox ~/Downloads/Telegram\ Desktop/ChatExport_01_02_2020/messages.html
If you need a more complete backup of all chats you can go to the central menu (3 small bars) on the top left, then "Settings" -> "Advanced" -> under "Data and Storage" choose "Export Telegram data". There you can also click checkboxes for what you are interested in. Near the bottom is aselection between HTML for humas, or machine-readable JSON.
On the very first export request it first requires you to confirm on another Telegram instance to allow the export request, to avoid misuse. Once you confirmed, e.g. from your mobile phone, you can go to export again and proceed as described above without any further confirmations.

Dart Editor Unable to run current selection - please select a runnable resource

Last year I thought I would give Dart a try, so I downloaded the Dart + Editor zip from the dartlang.org website and got it working on my Ubuntu 12.04 environment. When trying to get the Sunflower demo to run (by clicking the Run button), I got the "Unable to run current selection - please select a runnable resource" error. After exploring Google for answers, I found nothing, so I gave up on Dart at the time, not wanting to spend the time on something that is still buggy. Since then I prepared a completely new Ubuntu 14.04 environment on a new computer and thought I would give Dart another try. So I downloaded and installed it again this year and I am experiencing the exact same problem, still with no answers from Google searches. If this were a bug, I figured something like this would have been resolved after a year, or at least some discussion somewhere on Google about it. Am I doing something consistently wrong?
I extracted the dart zip into /opt/dart
I installed openjdk-7-jre
I executed DartEditor and it runs
I select the Sunflower demo
I click the green Run button
I get the following error: "Unable to run current selection - please select a runnable resource"
Any ideas?
Try the context menu on the entry page file (index.html or sunflower.html) in the web sub-directory and choose Run in Dartium
There is no unique or default entry point in a Dart package and no way to configure one.
You always have to run a specific Dart script file or HTML page that contains a ` tag.
I almost never used the run Button in the toolbar.
When you have for example the menu Run/Always run last launch activated and run an entry point like described above the toolbar run button should work to run the same entry point again.
I guess there are other ways to make this run button work but as I said, I almost never use this one myself.
Context menu Run in Dartium, Run as Javascript for web applications and context menu Run for command line scripts worked always for me.

Application Settings + IniFile + User Rights

Could you tell me please. I wrote an application that uses 'Settings.ini' to save settings. The application is installed using InnoSetup. If there are several user accounts and the application is installed in one of them, so, if I try to run the application from another account I get error "Unable to write to....". That is, if run from another account, the application has no rights to write to the settings file. I don't know what happens in Windows XP, but that's the way application behaves in Windows 7.
So could you tell me please, is there something I should define in my application to make it work for multiple users or it should be changed during the installation, somewhere in InnoSetup parameters?
Thank you.
You should - install the very program into Program Files or some other common folder - folder that any user have rights to read and run, but not to write or delete. USually installers would allow to override the folder, but the rule remains: every user should have non-destructive rights (read and execute) and none - destructive (delete, overwrite)
That means your installer should request Admin rights and UAC Elevation - ask InnoSetup forum or documentation how to do it. That may deal with including manifests resources into installer. It is normal when a regular user runs the installer and installer then asks for another username and password with admin rights.
The settings and other user-unique data should be saved into special per-user data folders. Usually that is AppLocal folder under user profile. However it is task for your application rather than the installer. Installer may create global settings templates, that the application would just copy into user-local settings on the 1st run under given user, or would override by user-local settings if cascading settings storage is implemented.
http://msdn.microsoft.com/en-us/library/windows/apps/hh465094.aspx
http://blogs.msdn.com/b/patricka/archive/2010/03/18/where-should-i-store-my-data-and-configuration-files-if-i-target-multiple-os-versions.aspx
Run command prompt, issue set command - and u would see all needed paths as environment variables wit hnames like AppPath, LocalAppPath and UserProfile
http://greatis.com/delphicb/tips/lib/systemifo-envstrings.html
http://www.delphidabbler.com/articles?article=6

Resources