Hi, i have two things i need help with.
1. Can cpau be run from within a vb file? I run this command
Set WsShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "cpau -u username -p password -ex " & """wscript.exe file.vbs " & """ -profile".
I have set the file.vbs script to echo the currently logged on user and it runs fine but only reports the non-admin user. If i run from a dos batch file it reports the supplied admin as the logged on user so the script is working. Any thoughts on where i have gone wrong? I cant use a batch file for this as i am restricted to scripts that have to be encoded.
I came across this script
' Explicit variable declaration and standard globals
Option Explicit
Dim g_sComputerName
Dim g_oShell, g_oFSO, g_oNet
' Set standard globals and create global objects
Set g_oShell = CreateObject("Wscript.Shell")
Set g_oFSO = CreateObject("Scripting.FileSystemObject")
Set g_oNet = CreateObject("WScript.Network")
g_sComputerName = g_oNet.ComputerName
' in this example the command prompt is being run as the administrator
' on the local computer.
g_oShell.Run "runas /user:" & g_sComputerName & "\administrator cmd.exe"
Wscript.Sleep 500
' change YourPasswordHere to the local computer administrator account password
' the password must be in the quotation marks
g_oShell.SendKeys "YourPasswordHere" & "{ENTER}"
g_oShell.AppActivate "cmd (running as local administrator)"
This works as is but i cant get it to work with a vbs script. It seems I have a problem with this line
g_oShell.Run """runas /user:" & g_sComputerName & "\administrator & "wscript.exe c:test.vbs " """.
I get either a "specified file cannot be found" error or "expected end of statement" error.
2. My second question is it is possible to check the registry for the existence of a specified key and then terminate the script if the key is present? I cant seem to find the way to do this.
Thanks in advance for any replies.
1. Can cpau be run from within a vb file? I run this command
Set WsShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "cpau -u username -p password -ex " & """wscript.exe file.vbs " & """ -profile".
I have set the file.vbs script to echo the currently logged on user and it runs fine but only reports the non-admin user. If i run from a dos batch file it reports the supplied admin as the logged on user so the script is working. Any thoughts on where i have gone wrong? I cant use a batch file for this as i am restricted to scripts that have to be encoded.
I came across this script
' Explicit variable declaration and standard globals
Option Explicit
Dim g_sComputerName
Dim g_oShell, g_oFSO, g_oNet
' Set standard globals and create global objects
Set g_oShell = CreateObject("Wscript.Shell")
Set g_oFSO = CreateObject("Scripting.FileSystemObject")
Set g_oNet = CreateObject("WScript.Network")
g_sComputerName = g_oNet.ComputerName
' in this example the command prompt is being run as the administrator
' on the local computer.
g_oShell.Run "runas /user:" & g_sComputerName & "\administrator cmd.exe"
Wscript.Sleep 500
' change YourPasswordHere to the local computer administrator account password
' the password must be in the quotation marks
g_oShell.SendKeys "YourPasswordHere" & "{ENTER}"
g_oShell.AppActivate "cmd (running as local administrator)"
This works as is but i cant get it to work with a vbs script. It seems I have a problem with this line
g_oShell.Run """runas /user:" & g_sComputerName & "\administrator & "wscript.exe c:test.vbs " """.
I get either a "specified file cannot be found" error or "expected end of statement" error.
2. My second question is it is possible to check the registry for the existence of a specified key and then terminate the script if the key is present? I cant seem to find the way to do this.
Thanks in advance for any replies.