Bad boy Warrior Posted October 11, 2006 Share Posted October 11, 2006 I have this script which i want it to run as an administrator across a domain with users who and normal standard usersset WshShell = CreateObject("WScript.Shell")WshShell.Run "runas /user:administrator@domain""cscript.exe \\server\share$\Script.vbs"""WScript.Sleep 100WshShell.Sendkeys "Password~"' Uninstall games from Windows XP '============================================================================= Dim Fso : Set Fso = CreateObject("Scripting.FileSystemObject") Set WshShell = WScript.CreateObject("WScript.Shell")sPrograms = WshShell.SpecialFolders("AllUsersPrograms") If (Fso.FolderExists(sPrograms & "\Games")) Then ' Create file for uninstalling games Set f = Fso.CreateTextFile("c:\windows\inf\wmdtocm.txt", True) f.WriteLine("[Components]")f.WriteLine("freecell=off")f.WriteLine("hearts=off") f.WriteLine("minesweeper=off") f.WriteLine("msnexplr=off") f.WriteLine("pinball=off") f.WriteLine("solitaire=off") f.WriteLine("spider=off") f.WriteLine("zonegames=off") f.Close WshShell.Run "sysocmgr.exe /i:c:\windows\inf\sysoc.inf /u:""c:\windows\inf\wmdtocm.txt"" /q", 1, True Fso.DeleteFolder(sPrograms & "\Games"), True End IfEverything below ' Uninstall games from Windows XP works fine if i run as administrator so i guess the problem is with the runas script - can anyone help?Thx Link to comment Share on other sites More sharing options...
Ctrl-X Posted October 11, 2006 Share Posted October 11, 2006 You've left out a space in the runas statement:WshShell.Run "runas /user:administrator@domain""cscript.exe \\server\share$\Script.vbs"""This should be:WshShell.Run "runas /user:administrator@domain ""cscript.exe \\server\share$\Script.vbs"""Note the space after "administrator@domain". Link to comment Share on other sites More sharing options...
Bad boy Warrior Posted October 11, 2006 Author Share Posted October 11, 2006 Thanks - that work but it caused a few problems that i cant figure out myself.When the script runs it does the following (see attachment)any ideas?thx in advance Link to comment Share on other sites More sharing options...
Ctrl-X Posted October 11, 2006 Share Posted October 11, 2006 The "permission denied" error is generated by line 13 in the script. This is the line where you're trying to create the "c:\windows\inf\wmdtocm.txt" file, so presumably the user running the script doesn't have the necessary NTFS permissions to create the file. Link to comment Share on other sites More sharing options...
Bad boy Warrior Posted October 11, 2006 Author Share Posted October 11, 2006 The "permission denied" error is generated by line 13 in the script. This is the line where you're trying to create the "c:\windows\inf\wmdtocm.txt" file, so presumably the user running the script doesn't have the necessary NTFS permissions to create the file.Ok that sorts that but any idea on the other problem? as it happens only when a user logs on and only if they have games installed.......... Link to comment Share on other sites More sharing options...
cluberti Posted October 11, 2006 Share Posted October 11, 2006 Run filemon (from sysinternals) while you are running the script, and it should tell you both where the access denied occurs on the disk, and what user was attempting the operation. Link to comment Share on other sites More sharing options...
Ctrl-X Posted October 12, 2006 Share Posted October 12, 2006 Ok that sorts that but any idea on the other problem? as it happens only when a user logs on and only if they have games installed..........It looks like sysocmgr is started multiple times, but I can't figure out why that is happening. You'll have to be more specific. The first "runas" script is used to start the second script, right? So that second one is the "\\server\share$\Script.vbs" script, correct? What is the name of the first script and how does it get started? Link to comment Share on other sites More sharing options...
gunsmokingman Posted October 12, 2006 Share Posted October 12, 2006 (edited) Add this to your script to see if it helps. Dim WinD : WshShell.ExpandEnvironmentStrings("%Windir%")Dim Cmd1 : Cmd1 = "sysocmgr.exe /i:" & WinD & "\inf\sysoc.inf /u:"Dim Inf1 : Inf1 = WinD & "\inf\wmdtocm.txt")WshShell.Run(Cmd1 & " " & Inf1), 1, True Edited October 12, 2006 by gunsmokingman Link to comment Share on other sites More sharing options...
Bad boy Warrior Posted October 12, 2006 Author Share Posted October 12, 2006 It looks like sysocmgr is started multiple times, but I can't figure out why that is happening. You'll have to be more specific. The first "runas" script is used to start the second script, right? So that second one is the "\\server\share$\Script.vbs" script, correct? What is the name of the first script and how does it get started?i first had 2 scripts one had runas only and second had the main script (to remove games) i used the 1st script to run the 2nd script as administrator but it didnt work so i recreated this script including the runas command. When you see the lineWshShell.Run "runas /user:administrator@domain""cscript.exe \\server\share$\Script.vbs"""this line is referring to the script itself in hope that it will run itself as admin (the UNC path is referring to itself) If im wrong and i can code this a different way pls advise.Add this to your script to see if it helps. Dim WinD : WshShell.ExpandEnvironmentStrings("%Windir%")Dim Cmd1 : Cmd1 = "sysocmgr.exe /i:" & WinD & "\inf\sysoc.inf /u:"Dim Inf1 : Inf1 = WinD & "\inf\wmdtocm.txt")WshShell.Run(Cmd1 & " " & Inf1), 1, TrueI added this line but it still didnt work. Could you explain where this code shodul be inserted?Thanks guys Link to comment Share on other sites More sharing options...
Ctrl-X Posted October 12, 2006 Share Posted October 12, 2006 i first had 2 scripts one had runas only and second had the main script (to remove games) i used the 1st script to run the 2nd script as administrator but it didnt work so i recreated this script including the runas command. When you see the lineWshShell.Run "runas /user:administrator@domain""cscript.exe \\server\share$\Script.vbs"""this line is referring to the script itself in hope that it will run itself as admin (the UNC path is referring to itself) If im wrong and i can code this a different way pls advise.Right, that's what I was afraid of... So the script starts and runs itself under an administrator account. Then that script again runs itself, and that script runs itself, and... You see where this is leading? Go back to using two scripts, or find a way to run the script with the required permissions. You could for instance run it as a Group Policy computer startup script. Link to comment Share on other sites More sharing options...
Bad boy Warrior Posted October 12, 2006 Author Share Posted October 12, 2006 Ill try to split them into 2 scripts and see what happens. How do i run it as a Group Policy computer startup script? Im currentl running via GP under Logon.Thx Link to comment Share on other sites More sharing options...
Bad boy Warrior Posted October 12, 2006 Author Share Posted October 12, 2006 Found starup script under comp config - did the trick. Thanks very much Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now