Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login




Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Donate Today!

Do you enjoy these
technical forums?
Donate Today! Click Here

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

djbourne (TechnicalUser)
6 Sep 12 11:46
Hello I have created a basic script for installing some printers see below

Dim multiPrinter, UNCpath1, UNCpath2
UNCpath1 = "\\server\printer1"
UNCpath2 = "\\server\printer2"
Set multiPrinter = CreateObject("WScript.Network")
multiPrinter.AddWindowsPrinterConnection UNCpath1
multiPrinter.AddWindowsPrinterConnection UNCpath2
WScript.Quit


This works fine for those with admin rights but doesn’t run well with those without.
I read that runas doesn’t work in srpits and found a vbs to exe convertor then tried this script below. Which I had edited from one found on microsoft’s website.

set WshShell = WScript.CreateObject("WScript.Shell")

WshShell.run "runas /user:Domain\User" 'Open command prompt
WScript.Sleep 1000
WshShell.SendKeys "password" 'send password
WshShell.SendKeys "{ENTER}"
WScript.Sleep 1000

'Run Copiers
WshShell.SendKeys "D:\copiers.EXE"
WshShell.SendKeys "{ENTER}"

set wshshell = nothing


This doesn’t work.

Can someone help by pointing out my failings or if there is another way to do the script as runas please.
I cant use ad or gpo for it and I want the users to run from their machine when able.
I have also got the vbs to vbe convertor to make the file secure.

It will run from a shared folder on the server.

Many thanks
Darren
djbourne (TechnicalUser)
6 Sep 12 12:03
I have also tried this one

set WshShell = WScript.CreateObject("WScript.Shell")

WshShell.run "runas /user:domain\user %comspec%" 'Open command prompt
WScript.Sleep 1000
WshShell.SendKeys "password" 'send password
WshShell.SendKeys "{ENTER}"
WScript.Sleep 1000

'Run Copiers
WshShell.SendKeys Chr(34) + "\\server\hemelcopiers.exe" + Chr(34)

WshShell.SendKeys "{ENTER}"

WshShell.SendKeys "exit" 'Close command prompt
WshShell.SendKeys "{ENTER}"
WScript.Sleep 1000


set wshshell = nothing
Geates (Programmer)
6 Sep 12 14:37
use Microsoft's PS Tools. http://technet.microsoft.com/en-us/sysinternals/bb...

psexec.exe \\machine_name -s -c c:\path\to\script.vbs

-Geates

"I hope I can chill and see the change - stop the bleed inside and feel again. Cut the chain of lies you've been feeding my veins; I've got nothing to say to you!"
-Infected Mushroom

"I do not offer answers, only considerations."
- Geates's Disclaimer

djbourne (TechnicalUser)
7 Sep 12 4:38
Would that be me pushing the script to each user with psexec? I am looking at hundreds of users in an XP and windows 7 environment thats why I want them to run it when they are in otherwise I would be running a push everyday for weeks.
Geates (Programmer)
7 Sep 12 10:39
Everyday for weeks on 100's of XP/7 machines? Does your environment use Active Directory? If so, your best bet would be to utilize the logon script option in each user's AD account (under the profile tab). That way, when a user logons on the a machine, the logon script is executed.

We use AD in our environment and each user account has the same logon script, logon.vbs. It is within that script that you can put the code your want to run.

logon.vbs

CODE

sub djbourne
   msgbox "Mashed Potatoes"
end sub

msgbox "Guess my favorite carb?"
djbourne 

-Geates

"I hope I can chill and see the change - stop the bleed inside and feel again. Cut the chain of lies you've been feeding my veins; I've got nothing to say to you!"
-Infected Mushroom

"I do not offer answers, only considerations."
- Geates's Disclaimer

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close