I am trying to update some files in my application. I am trying to download the file, rename the current file to (.old) and then rename the downloaded file to the original file name (.exe).
When I run it in XP, it works fine. In Windows7, it gives me an error saying that access is denied. If I run the app from my desktop shortcut and set the properties of the shortcut to run as administrator, it works but it also prompts me to run the app as an admin every time I run it. I'm already logged in as an admin, so I don't want to be prompted every time I run it.
Is there a way in my program to simply rename the file as an administrator?
This is my rename code:
Dim old_file_name As String = Now.TimeOfDay.TotalMilliseconds & ".old"
File.Move(Application.StartupPath & "\myprog.exe", Application.StartupPath _
& "\" & old_file_name)
In My case I found that there is no good (quiet) way to perform an operation on Windows7 as an administrator without being prompted for elevated privileges. One option is to have the end user change their UAC settings so they don't get prompted and this is not a viable option. Another to is change my program manifest but that results in a prompt for admin privileges every time they run it, also not very desirable. Another is to simply change the shortcut properties to run as administrator, but again, that prompts for admin privileges every time you run it. So what I ended up with is simply letting my program run a the normal user and when they want to upgrade the program, they choose to perform the upgrade. The upgrade is handled by a separate program (which gets called from my main program) that does have its manifest changed to run as administrator, which will prompt the user for privileges. This way, they only get prompted when they want to run the upgrade program.
Related
We have an application which shows up as an Excel ribbon.
We have installed the application in our test environment through administrator login. We are trying to make a per machine installation.(Please note that in production environment, the installation will be through system account).
When we login as user to the same PC, we don't see the excel addin in the Excel ribbons. We don't see the addins anywhere in the list of addins as well.
We have tried using Active setup,Userstat,setting the values of properties as ALLUSERS=1, RegisterForAllUsers= True, InstallScope= perMachine, InstallAllUsers = Everyone, RunActionsAsInvoker = True . Also the privileges has been changed from user to admin in all the cutom actions and in manifest file as well. All these changes where made as we understood that the application used to package is Addin express and so the msi creation with privileges as admin is possible.
Unfortunately none of these changes seems to help us.
What we would need is an msi which we can install on per machine basis.
From the situation mentioned in the question, we had tried a lot of options and finally following approach works for us:-
Create a package which would place a powershell shortcut in the startup folder.
The shortcut would in turn call or execute a powershell script.
The powershell script would
1. check if the registry key for that particular add-in is available in HKCU.
We had our registry key as "HKCU\Software\Manufacturer Name\Product Name" which in turn had a string value "Installed".
If the registry key is not available for the user, then install the package with tranform.
3.If the registry is already available, then script doesn't make any change.
The package is installed as an Admin and once the user logs in, then automatically the cmd file is executed and the add-in is installed.
Since this was the first version of the product, we didn't have to handle version compatibility.
I have a program I wrote in Visual Basic Express 2013 to put a classification banner at the top of the screen. I set up a scheduled task using ngen.exe which makes it run at login. The problem is that it doesn't run as admin so any non-privileged user can kill the task.
This program is to replace another program called Netbanner because there are a few issues with Netbanner. The program I wrote resolves all of these issues except for the admin issue. Netbanner is implemented exactly the same way (ngen.exe) but it won't let a non-privileged user kill the task.
I don't know if it is something in the program itself or I missed something in the deployment process.
This is the command used to deploy Netbanner which I duplicated to deploy mine:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\ngen.exe install "C:\Program Files\Microsoft\NetBanner\NetBanner.exe"
Also, these are the files in C:\Program Files\Microsoft\NetBanner:
NetBanner.exe
NetBanner.InstallState
NetBanner.pdb
NetBannerSchTask.xml
Any ideas?
Thanks.
You could try to go into the properties->Compatibility->Run this program as an administrator for the application.
Alternatively, you could do the same thing for a batch file that you can schedule to run on startup.
I'm trying to run a batch file from Windows 8 Task scheduler and I'm getting an access denied error on the command prompt for the following command line.
echo "Hello World" >> C:\File.txt
However, if I tick the checkbox "Run with higest privileges" under the task scheduler then it works fine.
The question is why do I require to tick the checkbox when I can run the batch manually without the "Run as administrator"?
A couple possibilities:
If a task is registered using the Administrators group for the security context of the task, then you must also make sure the Run with highest privileges check box is checked if you want to run the task.
If you are using the S4U functionality, make sure the Logon as batch job policy is set for the user.
Make sure the user account the task is using has write access to the C:\ directory
By default in modern Windows you cannot write to the root directory. Use "%temp%\file.txt" instead.
I am using the 7zip standalone .exe to unzip a file. I am using the Execute Process task for this. I have tested this over and over again on multiple machines and I know it works (at least in debug mode/visual studio). I have uploaded this package the server. I have created a job that calls said package from the Package Store. The package is not able to find the .exe no matter where I put it.
My first thought was to put the .exe on the C:\ drive, which failed. I have also failed in my attempts to place the .exe on a network location that the account the package is running under has full control over.
Basically, has anybody else had issues getting the Execute Process Task to find an executable when the package is uploaded to the server?
The error message is
Can't find 7za.exe in directory C:\7zip
I'll risk a downvote for being wrong, but I believe you have a permission issue.
You say it runs fine on other servers from BIDS, try it without BIDS. Call it from a command-line on a box that it works on.
dtexec.exe /file C:\HereComesTheUnzipper.dtsx
If that works, then repeat the step on the troublesome server. RDC into the box and try again
dtexec.exe /ser localhost /sq HereComesTheUnzipper
If that still works, then you are looking at an issue with the job. What account is the SQL Agent service running as? Is the SSIS job step running as a particular set of credentials? If so, is it a SQL Server login (which wouldn't map to anything on the physical box)? Regardless of what your answer is, the resolution will be to ensure the account has access to
7z.exe
whatever scratch area 7zip may use while unpacking files (I assume %temp%)
the output folder (C:\bin\7z.exe -e e:\data\MyThing.7z)
Per the subject... I made a Setup.exe with Inno Setup which is supposed to
install to "{pf}{#MyAppName}". It does so on Win XP and also Win 7 if I'm
logged in with admin rights, but if I try on Win 7 as a limited user, I get
this error message:
"Setup was unable to create the directory C:\Program Files\AppName".
What to do? I don't want (or need) the user to install as an admin.
If you want to install to %ProgramFiles%, you do need to install as an admin. Regular users don't have write access to %ProgramFiles% directory.
If installing to %ProgramFiles% is not a requirement, just let the user pick a destination directory, or install to {localappdata} instead of {pf}. {localappdata} is guaranteed to be writable for it's owner. It expands to something like C:\Users\<user name>\AppData\Local.
You can also install to {pf} if running as admin and to {localappdata} if running as restricted user; use IsAdminLoggedOn to decide.
If installing to %ProgramFiles% is a must, you have no choice but to run as admin.
For this to work correctly, make sure that your .iss file either does not define PrivilegesRequired option, or it's set to admin. Then, when an unprivileged user runs the installer, a UAC prompt will appear asking for credentials with enough access rights (unless UAC is disabled, in which case the only way to install is Run As).