Jump to content
Sign in to follow this  
MattX

RunAsSet

Recommended Posts

Can someone please tell me whats wrong with this before I smash one of my PCs up.........

RunAsSet("administrator", @ComputerName, "password")
Runwait(@comspec & " /c net stop Windows Firewall/Internet Connection Sharing (ICS)","",@sw_hide)
Run("p:\Games\Age Of Empires II Trial\empires2.cmd")

Error is:

Unable to execute the external program.

The directory name is invalid.

Is it because the service name has a / and and (ICS) in ?

If so, how do I get around this....?

Forgot to add I also tried calling a CMD file in with:

net stop "Windows Firewall/Internet Connection Sharing (ICS)"

In, this did not work either. However when I run this CMD manually - [ double click on it ] then it works...... :(

Edited by MattX

Share this post


Link to post
Share on other sites

hi,

also run('P:.....

won't work if it's an mapped drive.....

Andre


What about Windows without using AutoIt ?It would be the same as driving a car without an steering Wheel!

Share this post


Link to post
Share on other sites

Perhaps use this:

Run(@ComSpec & ' /c net stop SharedAccess', '', @SW_HIDE)

<{POST_SNAPBACK}>

SharedAccess ?

Could you explain please...

Share this post


Link to post
Share on other sites

SharedAccess ?

Could you explain please...

<{POST_SNAPBACK}>

I just use sc query to enumerate the service list. This gives the service names. You can use sc.exe, which has more features, rather then the net command. Both seem to do the start and stop, ok.

SERVICE_NAME: SharedAccess

DISPLAY_NAME: Windows Firewall/Internet Connection Sharing (ICS)

        TYPE              : 20  WIN32_SHARE_PROCESS

        STATE              : 4  RUNNING

                                (STOPPABLE,NOT_PAUSABLE,IGNORES_SHUTDOWN)

        WIN32_EXIT_CODE    : 0 (0x0)

        SERVICE_EXIT_CODE  : 0 (0x0)

        CHECKPOINT        : 0x0

        WAIT_HINT          : 0x0

Share this post


Link to post
Share on other sites

Thanks for the advice all - I got this working in the end in a sort of funny way - bit of spag code if you like but it did the trick...

I made 2 CMDs, one with:

net stop "Windows Firewall/Internet Connection Sharing (ICS)"

In. The other had:

p:

cd games

cd "age of empires 2 trial"

empires2.exe

Because for some reason if I ran the empires2.exe from autoit, [ not autoit, but Age Of Empires ] would error with a direct draw problem !!! Call it from a CMD and it worked fine, in fact thinking about it now I bet if I stuck in the working dir in Autoit it would work correctly....May try that tomorrow with the SharedAccess name in too...

My final autoit code was as follows:

; AutoIt Version:     3.10
; Language:         English
; Platform:         WinXP
; Author:             Matt Marsh - mmarsh@******.org.uk
; Script Function:  Script that turns off firewall then launches Age Of Empires 2
; Version:          1

SplashImageOn("resource_gui", "p:\misc\splash.jpg", "172", "168", "-1", "-1", 3)
Sleep(2000)
SplashOff()
SplashTextOn("aoe2", "Getting Ready To Launch Age Of Empires." & @CRLF & "Please Wait...", "350", "70", "-1", "-1", 3, "", "", "")
Sleep(3000)
BlockInput(1)
RunAsSet("administrator", @ComputerName, "password")
Run("c:\logs\sf.cmd")
RunAsSet()
Sleep(5000)
SplashOff()
BlockInput(0)
Run("c:\logs\empires2.cmd")
Exit

Just need to add to it for when they exit Age Of Empires so it re-starts the firewall - I'll work on that later....

Share this post


Link to post
Share on other sites

I have added a ProcessWaitClose bit at the end of the script which works great - I was wondering though just how much CPU this uses ?

I have hit the Windows key during the game [ not for me btw, this is for our year 8's end of term treat ] and when I bought up Task Manager its hardly doing anything !! The help file states it polls every 250 mill seconds - to me that would cause some usage on the CPU as its like a constant loop. Don't get me wrong, I am not complaining - just amazed at hole little CPU it uses....

Someone give me an explanation...

ProcessWaitClose("empires2.exe")
RunAsSet("administrator", @ComputerName, "password")
Run(@ComSpec & ' /c net start SharedAccess', '', @SW_HIDE)
RunAsSet()
SplashTextOn("aoe2", "Closing Down Age Of Empires." & @CRLF & "Please Wait...", "350", "70", "-1", "-1", 3, "", "", "")
Sleep(3000)
Exit

Share this post


Link to post
Share on other sites

Well, you can display this, to yourself. This may not be acurate, as inbuilt functions have sleeps etc. The examples below, should give you a visual idea.

This has the Sleep(250) the ProcessWaitClose() would look like?

Opt("SendKeyDelay", 0)
Run('notepad.exe')
WinWaitActive('Untitled')
$time = TimerInit()
For $i = 1 To 1000
    Sleep(250)
    Send('loop ' & $i & @CRLF)
    If TimerDiff($time) > 5000 Then ExitLoop
Next

Here is no wait.

Opt("SendKeyDelay", 0)
Run('notepad.exe')
WinWaitActive('Untitled')
$time = TimerInit()
For $i = 1 To 1000
    Send('loop ' & $i & @CRLF)
    If TimerDiff($time) > 5000 Then ExitLoop
Next

:(

If you want less cpu cycles being used, then created your own waiting method.

While ProcessExists("empires2.exe")
    Sleep(5000)
WEnd

Share this post


Link to post
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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...