I am working on a windows based c++ application. I have created the installer for this project using Visual Studio 2012. This project also has some configuration files, which are copied intothe installation folder(c:\program files\). When the application starts, one log file is also created in this installation directory.
Now the problem is when I install the application on a windows 7 system, which has admin rights, everything works fine. But, when I install this on a system, which does not have admin rights, that neither my application is able to read the config file present in the current directory, nor the log file gets generated.
How can I set/change the permission of this installation directory during the instllation, so that I can modify/read the config file and also log file gets created.
You need to decide if you want your application to have administrator privileges or not, because only an app with administrator privileges can modify/read the config file and create log file in a sub-directory of "Program Files".
If you are OK with this, then create an app that will open an UAC prompt when it is started, which request administrator privileges. To do this, open project property pages and go to "Linker->Manifest File", then set the value of "UAC execution level" to requireAdministrator. On the other hand, if you consider this to be an overkill, I suggest you change your app to create a directory in user folder. This folder will be used to store config file and log file. The most common approach is to create a folder in C:\Users\some_user\AppData\Local.
Please note that I would suggest the latter approach, there is no need to give an app administrator privileges just to keep config and log file in "Program Files". However, I am not familiar enough with your application, maybe an UAC prompt is a better solution. That is up to you to decide.
Related
I try to learn AWS and follow some manual from Udemy.
I try to follow the lesson where I need to manage the c:/Users/home/.aws directory. This folder contains users credentials, but I haven't this directory on my windows machine.
My steps:
I created windows server
Created user
The user is logined to the AWS-server
I connected to the windows-machine with Administrator credentials
Installed awscli
In the tutorial lector get to the c:/users/home/.aws directory, but I haven't such a folder on my machine. What is this folder and which actions do I need to execute?
-
I have four AHK scripts which run on startup, as they have shortcuts placed in my startup folder. How can I make them run as admin?
What I've tried:
I've tried changing their properties to be run as admin, but they just don't run (when I do that).
I've tried changing their shortcuts' properties to be run as admin, but they too just don't run (when I do that).
I've looked at this reddit post on the topic, but I don't know how to implement that code in the scripts.
I've tried creating a basic C++ application which runs them with system("start path\\to\\script"), but it wouldn't compile.
In case it matters, the scripts in question are ahk-active-screenshot, CtrlAlt_Switch.ahk, Kill.ahk, and a modified version of this search script.
You can allow the script to automate administrative programs without running as admin, here're the required steps:
When installing AHK, check the "Add 'Run with UI Access' to context menus" option.
After installation, find AutoHotkeyU64_UIA.exe on your disk.
Open the .ahk script's properties, change the "Open with" option to the AutoHotkeyU64_UIA.exe you just found.
Create a shortcut to this script.
Open %APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup in the file explorer.
Move that shortcut to this folder.
And you're done.
How does it work?
The "Add 'Run with UI Access' to context menus" option provides a workaround for common UAC-related issues by allowing the script to automate administrative programs without running as admin.
Reference: Run with UI Access.
Find the UIA version of autohotkey on your machine. For me it is at C:\Program Files\AutoHotkey\AutoHotkeyU64_UIA.exe.
In your startup folder, create a new shortcut (probably one for each of the scripts you want) as follows (replacing paths as appropriate):
Target: "C:\Program Files\AutoHotkey\AutoHotkeyU64_UIA.exe" "D:\path\to\script.ahk"
Start in: "C:\Program Files\AutoHotkey"
This launches your script as an admin using the UIA version of AHK on startup.
I've read several guides/stackoverflows but not found a similar situation/solution.
I have my remote ssh working (can browse files).
I don't get why I need a local Windows application (although I have a compiled .exe it's not the version I want to debug which is only on the Linux server).
When I try and launch a remote debug session it immediately fails with
Exception occurred during launch
Reason:
Error during file upload.
and below in the details
Could not write file: <my windows exe path>
Permission denied
...
The aforementioned file is writable and in any event I also started eclipse as administrator just in case.
In any event the .exe is irrelevant. I just want to debug code remotely.
(I know all about gdbserver...happy to manually kick that off if need be....don't think I'm there yet though)
Below is the options page I'm presented with:
Had the same experience on TI Code Composer Studio Version: 9.3.0.00012.
This seems to happen while uploading the cross compiled binary from host to target. If you set the check box "Skip download to target path" the error should disappear.
I propose to workaround the upload.
Setup a web server on the host, the line python.exe -m http.server --directory \source\hello\Debug\ would be sufficient
Run wget on the target, see screenshot
I recently created a c++ program for windows that when is launched, it reads some files that store the user configurations, if it is the first time the program runs, it store the options the user set and create the files. When I am debugging it in visual studio it works as expected.
So I proceded to create a setup for installation, I used Inno Setup. My program requiered to start at launch so I use the following code, this is from the inno website http://www.jrsoftware.org/iskb.php?startwithwindows. My problem is that when the programs start at launch these files are not read or created, but if I close the program and I launch the program using the desktop Icon it reads and creates de files.
So my question is there something in the Inno script that allows it to read the files? could be a problem with the fstream class?, could there be a code solution
Thanks in advance.
I followed Michael advice and I used the APPDATA folder with Roaming subfolder, and now the program read the config files and run as expected, thanks for the help!!.
From above comments, you say you are storing the configuration files in the same folder as the .exe, and your application is able to create the files when run from Visual Studio, but not when installed to the "Program Files (x86)" folder or C:/ root.
It sounds like you are running into UAC (User Access Control) permissions issues. The "Program Files (x86)" folder at least, and I believe C:/ (root) as well, require administrator privileges to write. This was not the case with Windows XP and older; it is with modern versions. You may be running Visual Studio as administrator and not know it, and allowing administrator privileges when you install, but the application is not then run as administrator so it cannot write to those locations.
Try running your (installed) application as administrator (right-click the file and select "Run as administrator"). If it works, there you go: you either have to run it as administrator always if you want it to be able to store configuration files in the same directory as the .exe, or else (much better solution) store your configuration files in an appropriately-named subdirectory of %APPDATA%, which the user running your application will always be able to write to without administrator privileges.
I developed a Custom application that is able to consume the CRM Web services and perform Windows Live Id authentication, create, read and update operation in the CRM from the custom .NET page. It runs absolutely fine when I debug the application in Visual Studio 2010 but when I deploy the same application and try to authenticate it shows the following error:
"Could not load file or assembly 'Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified."
I just wanted to know how to install the Microsoft.IdentityModel assembly using a startup task.I followed some of the steps in the following link:
http://blogs.msdn.com/b/sriharsha/archive/2012/04/07/windows-azure-unable-to-find-assembly-microsoft-identitymodel.aspx
But was unable to add RegisterDLL.cmd to my project solution.
Well,
You can use what Sandrino suggests, but you can also use this powershell script. I use it in couple of project and it works fine. It also auto-recognizes Windows Version (because for Azure Guest OS Family 1.xx you have to use the Windows6.0-xxxxx, and for Guest OS Family 2.xx you have to use Windows6.1-xxx version of the KB update).
You can execute that powershell script in a very simple startup task. Create one setup.cmd file, that you have the following content:
#echo off
powershell -command "Set-ExecutionPolicy Unrestricted" 2>> err.out
powershell .\Install-WIF-OnAzure.ps1 2>> err.out
And run it as simple startup task:
<WebRole name="AzureAndWif" vmsize="Small">
<Startup>
<Task commandLine="setup.cmd" executionContext="elevated" />
</Startup>
...
</WebRole>
Hope this also helps ;)
What do you mean by "was unable to add RegisterDLL.cmd to my project solution"? In Visual Studio, just follow these steps:
Right click on your project
Choose Add > New Item > Text File
Enter the following code (from the blog post):
#echo off
sc config wuauserv start= demand
wusa.exe "Windows6.1-KB974405-x64.msu" /quiet /norestart
sc config wuauserv start= disabled
exit /b 0
Rename the file to RegisterDLL.cmd
In the properties, set Copy to Output Directory to Copy always
Go to File > Save as. On the Save button, click the small arrow and choose Save with Encoding
Choose Unicode (UTF-8 without signature) - Codepage 65001
This should be enough to have a working file. Now follow the rest of the guide and redeploy your application.
If you are deploying this to Windows Azure then make sure "copy local" is set to true on the Microsoft.IdentityModel when you deploy to Azure.
-----------**Update**----------------------------
Cloud Tip #9-Add Microsoft.IdentityModel to the GAC with a Startup Task
http://blogs.msdn.com/b/benko/archive/2012/04/07/cloud-tip-9-add-microsoft-identitymodel-to-the-gac-with-a-startup-task.aspx
This should help...