Jump to content

Recommended Posts

Posted

Hi guys,

 

I have a very annoying issue (either that or I'm being blonde!)

I am trying to run this script to map part of a piece of software to teacher laptops, however the script doesn't work and I can't see where I am going wrong, even after changing certain parts of it.

 

Does anything look wrong with this?

 

set WshShell = CreateObject("WScript.Shell")

 

WshShell.Run "runas /user:exambase""\\hge-apps01\Packages\ExamWizard\Button_B.exe"""

 

WScript.Sleep 1000

 

WshShell.Sendkeys "Password1~"

 

WScript.Quit

 

 

Basically, the cmd prompt will appear, then within seconds a few lines of txt will appear and close the window before I can see what it says.

 

Any help would be appreciated.

Posted

@storkyIV:

 

Just to allow you to see what the cmd prompt is doing you could increase the sleep time to say 50000 which would be 50 seconds in essence. this might help you pin point what is actually happening. ;) :)

Posted
@storkyIV:

 

Just to allow you to see what the cmd prompt is doing you could increase the sleep time to say 50000 which would be 50 seconds in essence. this might help you pin point what is actually happening. ;) :)

 

Thanks Bossman. that was the 1st thing that I thought of - but it makes no difference. The cmd line flashes up, and i under a second disappears again! :mad::mad::mad::mad::mad:

Posted
What you could do is bring up command prompt and try to run the script from there, that will leave the command prompt open after the script has finished. Thats what I do for debugging.
Posted

I don't know if it's of any use, but here is a "Run As" script I've pinched and hacked at to get it to run some flippin French software that refuses to just run under normal user conditions. You might be able to use something from it possibly?

 

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

Set FileSystemObject = CreateObject("Scripting.FileSystemObject")
Set Drives = FileSystemObject.Drives
For Each DiskDrive in Drives
   DriveLetter = DiskDrive.DriveLetter
   DriveType = DiskDrive.DriveType

   If DriveType = "CD-ROM Drive" Then
CDDrive = DriveLetter
Exit For
   End If        
Next

Set Drives = nothing
Set FileSystemObject = nothing

strCmd="FileToRunAs.exe"
strUser="YOURDOMAIN\UserToRunAs"
strPass="P455W0RD!"
set WshShell=CreateObject("WScript.Shell")
WshShell.Run "runas.exe" & " /u:" & strUser & " " & CDDrive & strCmd
WScript.Sleep 1000
WshShell.Sendkeys strPass & "~"

 

It's probably more the bottom part you would be interested in as the top part simply looks to see which what letter the CD Drive is.

 

If I can help any from it, I'll do my best, but it's something I've found and hacked around a bit more than wrote from the bottom up!

 

Andy

:cool:

Posted


set WshShell = CreateObject("WScript.Shell")

WshShell.Run "runas /user:administrator@******.hereford.sch.uk """""

WScript.Sleep 1000

WshShell.Sendkeys "**********~"

WScript.Quit()

 

mine is identical to yours.. pinched fron the testbase install!

 

however, i have the full user@domain and a space at the end of the domain before the double quotes.

 

i suspect the missing space is the issue.

 

I hope this helps.

 

BoX

  • Thanks 1
Posted

How would you do this and pass a switch command?

 

Here's my script (It's to set a default pdf reader)

 

On Error Resume Next

strCmd="C:\PROGRA~1\FOXITS~1\FOXITR~1\FOXITR~1.EXE -register"

strUser="[email protected]"

strPass="Password"

set WshShell=CreateObject("WScript.Shell")

WshShell.Run "runas.exe" & " /user:" & strUser & " " & strCmd

WScript.Sleep 1000

WshShell.Sendkeys strPass & "~"

 

The command works from the command line as

 

runas.exe /user:me@there "C:\PROGRA~1\FOXITS~1\FOXITR~1\FOXITR~1.EXE -register"

 

But I can't pass the quote marks in the script, how would I do that?

Posted

Ok,

 

I can run the script on a machine that I am logged onto if I remove the run as and send keys statements from the script, so it is definately those eliments that are causing me grief!!!

Posted

Try putting the .exe on the end of the runas so your script is something like follows:

 

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

strCmd="\\hge-apps01\Packages\ExamWizard\Button_B.exe"
strUser="exambase"
strPass="P455W0RD!"
set WshShell=CreateObject("WScript.Shell")
WshShell.Run "runas.exe" & " /u:" & strUser & " " & strCmd
WScript.Sleep 1000
WshShell.Sendkeys strPass & "~"

 

Dunno if that will work or not (obviously set the password to whatever your password is and if it's a domain user, make sure you call it using the standard DOMAIN\User call instead of just the username - this is because just the username looks for a local user on that machine, and not a user on the network)

 

:cool:

Posted

set WshShell = CreateObject("WScript.Shell")

WshShell.Run "runas /user:administrator@******.hereford.sch.uk """""

WScript.Sleep 1000

WshShell.Sendkeys "**********~"

WScript.Quit()

 

mine is identical to yours.. pinched fron the testbase install!

 

however, i have the full user@domain and a space at the end of the domain before the double quotes.

 

i suspect the missing space is the issue.

 

I hope this helps.

 

BoX

 

Thank you very very much!

That was it - finally!

 

Cheers!

Posted

This seems to have been solved now but I had a very similar problem recently and it was a GPO not permitting me to access shared resources on the same server using more than one set of login credentials.

 

Basically I had a mapped drive setup with my login, then I was trying to map another share using Runas with a different account.

 

It wouldn't let m use two acccounts in the same session for mapped drives.

Posted
This seems to have been solved now but I had a very similar problem recently and it was a GPO not permitting me to access shared resources on the same server using more than one set of login credentials.

 

Basically I had a mapped drive setup with my login, then I was trying to map another share using Runas with a different account.

 

It wouldn't let m use two acccounts in the same session for mapped drives.

 

 

Was the share on the same server or DC? - It won't let you do it AFAIK.

  • Thanks 1
Posted

Yeah it was.

 

Got around it by changing the user credentials for my first mapped drive which is one I always need, now when I map the second drive using runas it doesn't mind becase the first share is mapped by the same account.

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



×
×
  • Create New...