Windows XP run a process with vbscript

Joined
Jun 2, 2005
Messages
3
Reaction score
0
Hello,

Is it possible to run a process with a user different of the current user, in order to limit the permission of this process ?
I have to use vbscript.

Thanks for yours answers.
Frédéric.
 
Joined
May 29, 2005
Messages
60
Reaction score
0
I'm not sure what you are asking. Do you mean on a website like for a forum or just for a login? Do you mean permissions for users on a computer?

...Remember VB script isn't viewable in all browsers.

Av
 
Joined
Jun 2, 2005
Messages
3
Reaction score
0
Thnaks for yours answer,

in fact I have an application in Java which wants to run , with a script, an other application with a different user, and I have to use vbscript.
 
Joined
Jun 2, 2005
Messages
3
Reaction score
0
J have resolved my problem, here after the script

'**************************************************
' Lancement d'une application sous uin user
' utilisation de la commande runas
'***********************************

sUser1="EU\st09346" ' user sous lequel est lancé l'aaplication
sCmd1="calc" ' application
sPass1="******"&CHR(13) ' remplacer ****** par le password associé au user

On Error Resume Next
dim WshShell,FSO

set WshShell = CreateObject("WScript.Shell")
set WshEnv = WshShell.Environment("Process")
WinPath = WshEnv("SystemRoot")&"\System32\runas.exe"
set FSO = CreateObject("Scripting.FileSystemObject")




rc=WshShell.Run("runas /user:" & sUser1 & " " & CHR(34) & sCmd1 & CHR(34), 2, FALSE)
Wscript.Sleep 30 'need to give time for window to open.
WshShell.AppActivate(WinPath) 'make sure we grab the right window to send password to
WshShell.SendKeys sPass1 'send the password to the waiting window.

set WshShell=Nothing
set oArgs=Nothing
set WshEnv=Nothing
set FSO=Nothing

wscript.quit
 
Joined
Jun 28, 2012
Messages
1
Reaction score
0
In case anyone comes across this post again, here is a cleaned up version of the vbscript code:
Code:
Option Explicit

Dim u, p, c, sh, env, path, rc

u = "username"
p = "password" & Chr(13)
c = "command"

Set sh = CreateObject("WScript.Shell")
Set env = sh.Environment("Process")
path = env("SystemRoot")&"\System32\runas.exe"

rc = sh.Run("runas /user:" & u & " " & Chr(34) & c & Chr(34), 2, False)
Wscript.Sleep 30     'need to give time for window to open.
sh.AppActivate(path) 'make sure we grab the right window to send password to
sh.SendKeys p        'send the password to the waiting window.

Set env = Nothing
Set sh=Nothing

WScript.Quit
 
Last edited:

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top