Sign in to follow this  
Followers 0
GregThompson

Running Script As a user it wasn't started with...

8 posts in this topic

I could write a start script that tells my main script to run as whatever user I want, but, what I would LIKE to do is sort of combine the 2 into 1. What I mean is.. I'd like a single script that checks to see who it's running as, and if it's not the specific user it needs to be, restarts itself running as the correct user. It should be simple enough to do using the RunAsSet command, however the first 1/2 eludes me? How do I check to see who the script is running as in the first place?

Share this post


Link to post
Share on other sites



I could write a start script that tells my main script to run as whatever user I want, but, what I would LIKE to do is sort of combine the 2 into 1. What I mean is.. I'd like a single script that checks to see who it's running as, and if it's not the specific user it needs to be, restarts itself running as the correct user. It should be simple enough to do using the RunAsSet command, however the first 1/2 eludes me? How do I check to see who the script is running as in the first place?

If @UserName <> "Flip" then
   RunAsSet ("Flip", @Computername, "Katrien")
   Run('"' & @ScriptFullPath & '"' ) 
   if @error = 1 then msgbox(48,"Error","cannot start ... wrong admin userid or psw")      
   exit 
EndIf

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Hi,

what is the goal of your task? Preventing users to start your script? Doing things always with one user? Is it a network pc or stand alone?

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

If @UserName <> "Flip" then
   RunAsSet ("Flip", @Computername, "Katrien")
   Run('"' & @ScriptFullPath & '"' ) 
   if @error = 1 then msgbox(48,"Error","cannot start ... wrong admin userid or psw")      
   exit 
EndIf
JdeB - @UserName determines the currently logged on user, not who the script is running as, thank you though.

Hi,

what is the goal of your task? Preventing users to start your script? Doing things always with one user? Is it a network pc or stand alone?

So long,

Mega

The goal is to always have the script start as a specific user no matter who starts it, the thing is, the user is a service account, so, in theory no one should ever be loggin on as that account. A "starter script" is easiet I know, but I wanted to get a little more fancy ya know? I didn't think I could user the @UserName variable because I thought it read from the winlogon hive, and the script would just keep on looping since the service account isn't logged on.

Share this post


Link to post
Share on other sites

JdeB - @UserName determines the currently logged on user, not who the script is running as, thank you though.

Did you try it ?

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Did you try it ?

mmhh think you are right .... back to the drawingboard...

Nope works as i thought it does.... try it..

Edited by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

mmhh think you are right .... back to the drawingboard...

Nope works as i thought it does.... try it..

I did try it, and I stand corrected. Thank you much! You may have a cookie now. :whistle:

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0