Logon Scripts

Zeddicus

Member
Oct 10, 1999
67
0
0
I have a situation where i need to insert a logon script in order to call an exe file that will install a piece of software when our network users log onto the network. These users are assigned basic "user level" access to their logon accounts and the software requires administrator level access.

The software exe file is located on a share that is mapped as an H: drive for each user that logs into our network


Here is the script I have written so far


<job>
<script language="vbscript">
oShell.Run "runas /noprofile /user:Administrator ""H:\RunThis\Clients\RunThis.exe"""
WScript.Sleep 50
oShell.Sendkeys "admin~"
</script>
</job>


the problem is i am getting a windows script host error dialogue box when the script tries to run.

here is some of the info from the error

Object Required: 'oShell"

Line 3

Character 2



I know next to nothing about writing scripts. the script language i have written so far was copied from a help website i found when doing a search for calling an exe file from a script. from there i altered the file path and exe filename as well as the administrator account name and password.

What I was hoping it would do is assign administrator rights to the machines that logon with this script and then run the exe file.


Any help is appreciated, thanks





 

jlazzaro

Golden Member
May 6, 2004
1,743
0
0
before you can run a string in the cmd window, you need to first define the variable oShell and set it to the shell. try and use this:

Dim oShell
Set oShell = WScript.CreateObject ("WScript.shell")
 

Zeddicus

Member
Oct 10, 1999
67
0
0
the script now looks like this

<job>
<script language="vbscript">
Dim oShell
Set oShell = WScript.CreateObject ("WScript.shell")
oShell.Run "runas /noprofile /user:Administrator ""H:\RunThis\Clients\RunThis.exe"""
WScript.Sleep 50
oShell.Sendkeys "admin~"
</script>
</job>


I get an error on line 5 character 2

the system cannot find the file specified


im thinking that this might be an access error and the script is erroring out when it doesnt have the proper rights to run the file.

im going to try a test run and assign a machine admin rights and see if it goes.
 

Zeddicus

Member
Oct 10, 1999
67
0
0
this is the sample script that i was using. to creat my script.
I tried assigning administrator rights and still get the same error as above. i triple checked my path and filename and all seems ok there.

What is the -nohome line in the script for?



Option explicit
dim oShell
set oShell= Wscript.CreateObject("WScript.Shell")
' Replace the path with the program you wish to run c:\yada\yada\yada
oShell.Run "runas /noprofile /user:administrator ""C:\Program Files\Internet Explorer\iexplore.exe -nohome"""
WScript.Sleep 100
'Replace the string yourpassword~ below with
'the password used on your system. Include tilde
oShell.Sendkeys "yourpasswordhere~"
Wscript.Quit
 

spyordie007

Diamond Member
May 28, 2001
6,229
0
0
I have a situation where i need to insert a logon script in order to call an exe file that will install a piece of software when our network users log onto the network. These users are assigned basic "user level" access to their logon accounts and the software requires administrator level access.
Login scripts are executed as the user logging in, if they dont have admin privilages but the script requires it than the script will fail.

You might want to look at using a computer startup script to do this since that runs as local system, keep in mind that you'll have to stick the shared files somewhere the computer accounts can reach them (unc path, privilages, etc.). This is generally a much better option than trying to do a runas (since that would expose the credentials to the user's account).

Good luck