Jump to content

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


Recommended Posts

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?

Link to comment
Share on other sites

  • Developers

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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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

Link to comment
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.
Link to comment
Share on other sites

  • Developers

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

Did you try it ?

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers

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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...