[SOLVED]Help with a simple script...
Verfasst: 06 Feb 2014, 15:08
Hello again,
I'm starting to create a few simple scripts, but I'm having a bit of trouble. I'm trying to create a script to add a local user account to windows 7.
Here's the script:
Even though the script executes the net commands, it cannot interpret the "if" statements, and I always get the following error on the log:
The key error that keeps appearing is this one:
Can you spot what I'm doing wrong?
Thanks
I'm starting to create a few simple scripts, but I'm having a bit of trouble. I'm trying to create a script to add a local user account to windows 7.
Here's the script:
Code: Alles auswählen
[Actions]
DefVar $username$
DefVar $fullname$
DefVar $password$
DefVar $isAdmin$
DefVar $syslanguage$
Set $username$ = GetProductProperty("user_name", "my_username")
Set $fullname$ = GetProductProperty("user_fullname", "my_fullname")
Set $password$ = GetProductProperty("password", "my_password")
Set $isAdmin$ = GetProductProperty("is_admin", "true")
Set $syslanguage$ = GetRegistryStringValue("[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Nls\Language] Default")
Message "Adding user to local machine"
winbatch_adduser
[winbatch_adduser]
if ($isAdmin$ = "true")
net user $username$ $password$ /add /passwordreq:yes /fullname:"$fullname$"
if ($syslanguage$ = "0816")
net localgroup Administradores $username$ /add
else
net localgroup Administrators $username$ /add
endif
else
net user $username$ $password$ /add /passwordreq:yes /fullname:"$fullname$"
endif
Code: Alles auswählen
[5] [Fev 06 13:42:54:534] [win7-add-local-user] Execution of winbatch_adduser
[6] [Fev 06 13:42:54:534] [win7-add-local-user] Call "if (False = "true")"
[6] [Fev 06 13:42:54:534] [win7-add-local-user] Waiting until the called process is finished
[6] [Fev 06 13:42:54:535] [win7-add-local-user] Start process as invoker: SYSTEM
[3] [Fev 06 13:42:54:535] [win7-add-local-user] Exception in StartProcess_cp: Failed to execute if (False = "true") : 2
[6] [Fev 06 13:42:54:535] [win7-add-local-user]
[6] [Fev 06 13:42:54:536] [win7-add-local-user] Call "net user test2 password /add /passwordreq:yes /fullname:"Test User 2""
[6] [Fev 06 13:42:54:536] [win7-add-local-user] Waiting until the called process is finished
[6] [Fev 06 13:42:54:536] [win7-add-local-user] Start process as invoker: SYSTEM
[6] [Fev 06 13:42:55:551] [win7-add-local-user] ExitCode 0 Executed process "net user test2 password /add /passwordreq:yes /fullname:"Test User 2""
[6] [Fev 06 13:42:55:551] [win7-add-local-user] Call "if (0816 = "0816")"
[6] [Fev 06 13:42:55:551] [win7-add-local-user] Waiting until the called process is finished
[6] [Fev 06 13:42:55:552] [win7-add-local-user] Start process as invoker: SYSTEM
[3] [Fev 06 13:42:55:552] [win7-add-local-user] Exception in StartProcess_cp: Failed to execute if (0816 = "0816") : 2
[6] [Fev 06 13:42:55:553] [win7-add-local-user] ExitCode 0 Executed process "net user test2 password /add /passwordreq:yes /fullname:"Test User 2""
[6] [Fev 06 13:42:55:553] [win7-add-local-user] Call "net localgroup Administradores test2 /add"
[6] [Fev 06 13:42:55:553] [win7-add-local-user] Waiting until the called process is finished
[6] [Fev 06 13:42:55:553] [win7-add-local-user] Start process as invoker: SYSTEM
[6] [Fev 06 13:42:56:570] [win7-add-local-user] ExitCode 0 Executed process "net localgroup Administradores test2 /add"
[6] [Fev 06 13:42:56:570] [win7-add-local-user] Call "else"
[6] [Fev 06 13:42:56:570] [win7-add-local-user] Waiting until the called process is finished
[6] [Fev 06 13:42:56:571] [win7-add-local-user] Start process as invoker: SYSTEM
[3] [Fev 06 13:42:56:571] [win7-add-local-user] Exception in StartProcess_cp: Failed to execute else : 2
[6] [Fev 06 13:42:56:571] [win7-add-local-user] ExitCode 0 Executed process "net localgroup Administradores test2 /add"
[6] [Fev 06 13:42:56:571] [win7-add-local-user] Call "net localgroup Administrators test2 /add"
[6] [Fev 06 13:42:56:571] [win7-add-local-user] Waiting until the called process is finished
[6] [Fev 06 13:42:56:571] [win7-add-local-user] Start process as invoker: SYSTEM
[6] [Fev 06 13:42:57:588] [win7-add-local-user] ExitCode 2 Executed process "net localgroup Administrators test2 /add"
[6] [Fev 06 13:42:57:588] [win7-add-local-user] Call "endif"
[6] [Fev 06 13:42:57:588] [win7-add-local-user] Waiting until the called process is finished
[6] [Fev 06 13:42:57:588] [win7-add-local-user] Start process as invoker: SYSTEM
[3] [Fev 06 13:42:57:589] [win7-add-local-user] Exception in StartProcess_cp: Failed to execute endif : 2
[6] [Fev 06 13:42:57:589] [win7-add-local-user] ExitCode 2 Executed process "net localgroup Administrators test2 /add"
[6] [Fev 06 13:42:57:589] [win7-add-local-user] Call "else"
[6] [Fev 06 13:42:57:589] [win7-add-local-user] Waiting until the called process is finished
[6] [Fev 06 13:42:57:589] [win7-add-local-user] Start process as invoker: SYSTEM
[3] [Fev 06 13:42:57:589] [win7-add-local-user] Exception in StartProcess_cp: Failed to execute else : 2
[6] [Fev 06 13:42:57:589] [win7-add-local-user] ExitCode 2 Executed process "net localgroup Administrators test2 /add"
[6] [Fev 06 13:42:57:589] [win7-add-local-user] Call "net user test2 password /add /passwordreq:yes /fullname:"Test User 2""
[6] [Fev 06 13:42:57:589] [win7-add-local-user] Waiting until the called process is finished
[6] [Fev 06 13:42:57:590] [win7-add-local-user] Start process as invoker: SYSTEM
[6] [Fev 06 13:42:58:606] [win7-add-local-user] ExitCode 2 Executed process "net user test2 password /add /passwordreq:yes /fullname:"Test User 2""
[6] [Fev 06 13:42:58:606] [win7-add-local-user] Call "endif"
[6] [Fev 06 13:42:58:606] [win7-add-local-user] Waiting until the called process is finished
[6] [Fev 06 13:42:58:606] [win7-add-local-user] Start process as invoker: SYSTEM
[3] [Fev 06 13:42:58:607] [win7-add-local-user] Exception in StartProcess_cp: Failed to execute endif : 2
[6] [Fev 06 13:42:58:607] [win7-add-local-user] ExitCode 2 Executed process "net user test2 password /add /passwordreq:yes /fullname:"Test User 2""
[1] [Fev 06 13:42:58:610] [win7-add-local-user] ___________________
[1] [Fev 06 13:42:58:610] [win7-add-local-user] script finished
[1] [Fev 06 13:42:58:610] [win7-add-local-user] 6 errors
[1] [Fev 06 13:42:58:610] [win7-add-local-user] 0 warnings
Code: Alles auswählen
[6] [Fev 06 13:42:54:534] [win7-add-local-user] Call "if (False = "true")"
[6] [Fev 06 13:42:54:534] [win7-add-local-user] Waiting until the called process is finished
[6] [Fev 06 13:42:54:535] [win7-add-local-user] Start process as invoker: SYSTEM
[3] [Fev 06 13:42:54:535] [win7-add-local-user] Exception in StartProcess_cp: Failed to execute if (False = "true") : 2
Thanks