fly Posted March 1, 2006 Posted March 1, 2006 Okay, this seemed like an easy enough idea to code in Autoit, but its turning out not to be....I have a batch file on SERVER1 that I want to get PC1 to run from my desk. The user logged on to PC1 doesn't have access to the file...* Tried PSExec. PSExec seems to work inconsistant, at best. Probably 50% of the time, it fails.* Tried BeyondExec, but it fails when attempting to use an ID/Pass (which is explicitly required to access the network). * Finally, I tried writing something in VBS and WMI to start the process, thinking I could make a snazzy ASP page for it. Apparently, WMI doesn't support spawning a process (with alternate credentials) that requires network access.So, anyone have any other ideas before I pull my hair out?
Daemonforce Posted March 2, 2006 Posted March 2, 2006 What the hell is PSExec and BeyondExec? o.OI'm having a similar problem here. I deploy Windows XP SP2 to several machines and I have a nasty habit of not checking the remote desktop connection switch for remote tasks. The remote registry service is running but outside of that, I can't connect remotely and I can't get it working. I used to be able to do this without a problem when we used SP1.I commonly use WMI to make changes like this and it's not working anymore. The technician box is running XP SP2 as well.
gunsmokingman Posted March 2, 2006 Posted March 2, 2006 Post your WMI scripts and maybe I can help with them.
fly Posted March 2, 2006 Author Posted March 2, 2006 Post your WMI scripts and maybe I can help with them.Sadly I deleted most of it while testing, but here's what I have left... It's pretty basic.sComputer = "bc007576"sBatchFile = "echo.vbs"Set oWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & sComputer & "\root\cimv2:Win32_Process")sCommand = "calc"errReturn = oWMIService.Create(sCommand, null, null, iProcessID)If errReturn = 0 Then Wscript.Echo sCommand & " was started with a process ID of " & iProcessID & "."Else Wscript.Echo sCommand & " could not be started due to an error " & errReturn & "."End IfInitially, the 'sBatchFile' was copied to the remote PC and then called in 'sCommand'. Whatever I copy and call won't attach to the network though. Thanks for any help.
gunsmokingman Posted March 2, 2006 Posted March 2, 2006 (edited) Here can you test this script, I cannot test it as I do not have any remote machine to connect to.If this does not work then could you get the Ip address and then I can try making a script that connectusing the IP address instead.Note * I have added all the Const for the way the app runs Const SW_HIDE = 0 ' Hides the window and activates another window.Const SW_NORMAL = 1 ' Activates and displays a window. If the window is minimized or maximized, the system restores it to the original size and position. An application specifies this flag when displaying the window for the first time. Const SW_SHOWMINIMIZED = 2 ' Activates the window, and displays it as a minimized window. Const SW_SHOWMAXIMIZED = 3 ' Activates the window, and displays it as a maximized window. Const SW_SHOWNOACTIVATE = 4 ' Displays a window in its most recent size and position. This value is similar to SW_SHOWNORMAL, except that the window is not activated. Const SW_SHOW = 5 ' Activates the window, and displays it at the current size and position. Const SW_MINIMIZE = 6 ' Minimizes the specified window, and activates the next top level window in the Z order. Const SW_SHOWMINNOACTIVE = 7 ' Displays the window as a minimized window. This value is similar to SW_SHOWMINIMZED, except that the window is not activated. Const SW_SHOWNA = 8 ' Displays the window at the current size and position. This value is similar to SW_SHOW, except that the window is not activated. Const SW_RESTORE = 9 ' Activates and displays the window. If the window is minimized or maximized, the system restores it to the=original size and position. An application specifies this flag when restoring a minimized window. Const SW_SHOWDEFAULT = 10 'Sets the show state based on the SW_ value that is specified in the STARTUPINFO structure passed to the CreateProcess function by the program that starts the application. Const SW_FORCEMINIMIZE = 11 ' Windows Server 2003, Windows 2000, and Windows XP: Minimizes a window, even when the thread that owns the window is hung. Only use this flag when minimizing windows from a different thread.strComputer = "bc007576"strCommand = "Calc.exe" Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" _ & strComputer & "\root\cimv2")' Configure the Calc process to show a windowSet objStartup = objWMIService.Get("Win32_ProcessStartup")Set objConfig = objStartup.SpawnInstance_objConfig.ShowWindow = SW_NORMAL' Create Calc processSet objProcess = objWMIService.Get("Win32_Process")intReturn = objProcess.Create _ (strCommand, Null, objConfig, intProcessID)If intReturn <> 0 Then Wscript.Echo "Process could not be created." & _ vbcrlf & "Command line: " & strCommand & _ vbcrlf & "Return value: " & intReturnElse Wscript.Echo "Process created." & _ vbcrlf & "Command line: " & strCommand & _ vbcrlf & "Process ID: " & intProcessIDEnd If Edited March 2, 2006 by gunsmokingman
fly Posted March 2, 2006 Author Posted March 2, 2006 It doesn't show calc on the machine, yet I show it running on the user's machine with my credentials. Can you confirm that WMI will allow network access when impersonating?
gunsmokingman Posted March 2, 2006 Posted March 2, 2006 It doesn't show calc on the machine, yet I show it running on the user's machine with my credentials. Can you confirm that WMI will allow network access when impersonating?I am not to sure about that, I will look around and see if I can find any inforamtion on that.try to change thisSet objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" _ & strComputer & "\root\cimv2")to this and see if it makes a differenceSet objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")Here is another script that you may want to trystrComputer = "bc007576"sBatchFile = "echo.vbs"Dim Act : Set Act = CreateObject("Wscript.Shell")Set oWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2:Win32_Process")If strComputer <> True Then Act.run "calc.exe",1,False ElseIf Error = 0 Then Act.Popup "Cannot Start Calc.exe On : " & strComputerEnd If
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