Sign in to follow this  
Followers 0
james3mg

RunAsSet with blank password

4 posts in this topic

There's a very simple script I'm making for my home computer, which has two accounts besides administrator, neither of which has a password. I want to change the screensaver for both accounts to blank at 10:00pm and back to the old screensaver at 6:00am.

I figured if I call the program from Windows' scheduled tasks, I could then set runas credentials and, based on the current hour, call itself with an "on" or "off" switch. Then it would write the appropriate value via RegWrite() in HKCU\Control Panel\Desktop\SCRNSAVE.EXE. The problem is that I can't seem to RunAsSet() if I gave it a username but no password, just as the help file command syntax implies. I also tried setting it like RunAsSet("username",@COMPUTERNAME,"") (providing a "blank" password), but then the RunWait() command fails.

Is there a way to run as a user if the user doesn't have a password, or is that completely disabled in XP like MSTSC logons?

Thanks


"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

There's a very simple script I'm making for my home computer, which has two accounts besides administrator, neither of which has a password. I want to change the screensaver for both accounts to blank at 10:00pm and back to the old screensaver at 6:00am.

I figured if I call the program from Windows' scheduled tasks, I could then set runas credentials and, based on the current hour, call itself with an "on" or "off" switch. Then it would write the appropriate value via RegWrite() in HKCU\Control Panel\Desktop\SCRNSAVE.EXE. The problem is that I can't seem to RunAsSet() if I gave it a username but no password, just as the help file command syntax implies. I also tried setting it like RunAsSet("username",@COMPUTERNAME,"") (providing a "blank" password), but then the RunWait() command fails.

Is there a way to run as a user if the user doesn't have a password, or is that completely disabled in XP like MSTSC logons?

Thanks

Can you post your code and exact error messages?

Also, when you run programs from the Task sheduler, they will automatically run as System. you dont need to do a runas at that point.

hope that helps.

Edited by blademonkey

---"Educate the Mind, Make Savage the Body" -Mao Tse Tung

Share this post


Link to post
Share on other sites

Also, when you run programs from the Task sheduler, they will automatically run as System. you dont need to do a runas at that point.

When a program is launched from Task Scheduler, it will actually run as whatever user's credentials you provide when creating the task, I believe. In my case, I gave it "administrator" and the corresponding password. But if I then use RegRead or RegWrite in the HKCU, it will look at administrator's registry, not the two other users. That is why I chose to do it this way.

In the meantime, I found that you can't "RunAs" a user with a blank password. So I figured I'd just set a temporary password for each user (by running _RunDOS('net user username newpassword') then unset it again using _RunDOS('net user username ""') ). The passwords are indeed set then cleared, but the program is still unable to run the program using the credentials. The code is below:

#include <Process.au3>

Global $User1 = "Username1"
Global $User2 = "AnotherUsername"
Global $TmpPass = "1234"

AutoItSetOption("RunErrorsFatal","0")
If $CmdLine[0] Then
  If $CmdLine[1] = "Off" Then
    RegWrite("HKCU\Control Panel\Desktop","MonOffScr",RegRead("HKCU\Control Panel\Desktop","SCRNSAVE.EXE",""))
    RegWrite("HKCU\Control Panel\Desktop","SCRNSAVE.EXE","C:\WINDOWS\system32\scrnsave.scr")
    Exit
  EndIf
  If $CmdLine[1] = "On" Then
    RegWrite("HKCU\Control Panel\Desktop","SCRNSAVE.EXE",RegRead("HKCU\Control Panel\Desktop","MonOffScr",""))
    Exit
  EndIf
Else
  $PID = _RunDOS('net user ' & $User1 & ' ' & $TmpPass)
  ProcessWaitClose($PID)
  RunAsSet($User1,@COMPUTERNAME,$TmpPass)
  If @HOUR = "22" Then
    RunWait(@ScriptFullPath & " Off")
    If @error Then MsgBox(0,"Error","There was a problem turning off " & $User1 & "'s screensaver")
  EndIf
  If @HOUR = "6" Then
    RunWait(@ScriptFullPath & " On")
    If @error Then MsgBox(0,"Error","There was a problem restoring " & $User1 & "'s screensaver")
  EndIf
  _RunDOS('net user ' & $User1 & ' ""')

  $PID = _RunDOS('net user ' & $User2 & ' ' & $TmpPass)
  ProcessWaitClose($PID)
  RunAsSet($User2,@COMPUTERNAME,$TmpPass)
  If @HOUR = "22" Then
    RunWait(@ScriptFullPath & " Off")
    If @error Then MsgBox(0,"Error","There was a problem turning off " & $User2 & "'s screensaver")
  EndIf
  If @HOUR = "6" Then
    RunWait(@ScriptFullPath & " On")
    If @error Then MsgBox(0,"Error","There was a problem restoring " & $User2 & "'s screensaver")
  EndIf
  _RunDOS('net user ' & $User2 & ' ""')
EndIf

Any obvious problems, anyone? I think this code has to be run from a compiled .exe program so it can call itself correctly with RunWait(@ScriptFullPath & " switch")

Thanks


"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110

Share this post


Link to post
Share on other sites

Promise I won't do this more than once :P , but I'd really like to figure out what I'm doing wrong, and I've exhausted everything I can think of. So I'm going to reply to give this thread one more chance at the top, then I'll let it die and keep looking for third-party apps.

If you have any suggestions, thanks.


"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110

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  
Followers 0