02-02-2009 05:40 AM
02-02-2009 06:56 AM
Hi Wiebe,
There's a tool called pcwrunas, it's basically the same as the built in runas but supports passing the password in the command line.
The tool is available on PCWelt (german only...): pcwrunas
I didn't try, but I hope this should work with system exec.
Hope this helps,
Daniel
02-02-2009 08:40 AM
02-02-2009 09:10 AM
02-02-2009 10:19 AM
This doesn't sound that nice...
Probably there are other tools around that can do the same?
A quick search also returned vbs script. This just programmatically enters the password in the runas dialog box.
Daniel
02-02-2009 11:29 AM
I use an organizational solution provided in the issue 15 2004 of the c't magazine. Some games will only run in admin mode on W2K SP4 and XP SP2 and I don't want my children to login as admins. Additionally I didn't want to spent the time to analyze with regmon and filemon where to set any rights.
Today I have Win XP Prof. SP2 running on my machine and I use the following solution.
If only user X will run your app and needs to start another program as admin you need to do the following thing during installation. Install the program (you are logged in as admin so you know the password). Then login as user X. Open cmd.exe and type:
runas /user:admin /savecred <theapp>
You will be asked for the admin password. Give it and stop the application.
Next time the password is not needed.
Now create a small cmd file containing the line above and call the cmd file from your app with the system exec vi.
02-02-2009 04:45 PM
Waldemar, that sounds to be a greate issue. I run into the problem once, that a device needed the app to be run in an admin account. but the operators should be normal useres by factory policy. I refactored the code to have the device driver VIs run as system service, called via Open VI ref. But it really comlicates the code. And it took me three days to have all running, while every time the program was quit or crashed, I had to run to the floor to login for the 'run as' command. And the operators went crazy, when I left for the weekend on 19:30 on friday....
Felix
02-03-2009 04:40 AM
02-03-2009 01:11 PM - edited 02-03-2009 01:12 PM
Wiebe wrote: But runas can't be runned by an application...
Not directly but as part of a command file. I have an app named Drive Snapshot which requires admin rights and checks this during startup. As a restricted user I created a command file named DriveSnapshot.cmd with the following line:
runas /user:admin /savcred F:\Programme\SnapShot\snapshot.exe
Double clicking in Windows Explorer requires the password entered. The next time time it will simply start without a prompt.
Next I created the following VI:
Running the VI will start the commandfile and therefore start DriveSnapShot.
Next I logout and login as admin and changed the password. Then I login as the previous restricted user. Running the VI DriveSnapShot will not start. You need to provide the password again.
For the permanent change of passwords this is not a solution for Wiebe.
Talking to system administrators they maybe make the following solution possible:
Creating a special user in the domain with admin rights. This user wil never change his password and is only known to the application programmer and the admins.
02-04-2009 03:40 AM