Here is a VB Script Vall Script that will get around the Password Prompt when "RunAs" is called...
'Start
'-----------------------------------------------------------------------------------
' To Run other VB Scripts or even Batch Files with Admin Priviliges'
'----------------------------------------------------------------------------------
Dim WshShell, objFSO
suser = "
YourAdminAccount@YourDomain.com"
sPass = "YourPassWord"
'------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
'Put your Domain Account and Password in between the qoutes, REMEMBER! the Password will be clear text. If this is a standalone just take off the @YourDomain.com
'-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
sCommand = "wscript \UNCServerNameShareFolderYourScript.vbs"
'--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
'This will be the path were the scripted you want called will be at. Please note you can substitute the ablove for a local directory (Example: C:FolderYourScript.vbs)
'-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Set objComputer = CreateObject("Shell.LocalMachine")
Set WshNetwork = CreateObject("WScript.Network")
Set WshShell = CreatObject("WScript.Shell")
Set WshEnv = wshShell.Environment("Process")
WinPath = WshEnv("SystemRoot")&"System32runas.exe"
rc = WshShell.Run ("runas /noprofile /user:" & suser & " " $ Chr(34) & sCommand & Chr(34))
WScript.Sleep 900
WshShell. AppActivate(WinPath)
WScript.quit
'End
Now my problem: my users account name is:
"user's"
When running above proposed script, I get the following error:
Windows Script Host
Script: C:VBSCstartMA.vbs
Line: 20
Character: 60
Error: Invalid character
Code: 800A0408
Source: Microsoft VBScript compilation error.
My guess is that my users name User's is giving troubles. I tried a few combinations, but I keep getting this error.
Last thing I tried is:
'----------------------------------------------------------------------------------
Dim WshShell, objFSO
suser = "user"& chr(7) &"s"
sPass = "welkom"
'------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Also tried: suser = "user's" and "user"'"s" or even "user""& chr(7) &""s" and "user& chr(7) &s"...
As you can see, I don't know squad ;p
Could you help me out? I just wanna run the following Start Menu Cleanup script:
'#==============================================================================
'#==============================================================================
'# SCRIPT.........: CleanUpStartMenuItems.vbs
'# AUTHOR.........: Stuart Barrett
'# VERSION........: 1.0
'# CREATED........: 11/11/11
'# LICENSE........: Freeware
'# REQUIREMENTS...:
'#
'# DESCRIPTION....: Cleans up any Start Menu folders containing broken
'# shortcuts
'#
'# NOTES..........: Untested on Windows 7!!
'#
'# Will ask before deleting any folders (can be amended
'# as per noted in script)
'#
'# You can add as many excluded folders as required.
'#
'# CUSTOMIZE......:
'#==============================================================================
'# REVISED BY.....:
'# EMAIL..........:
'# REVISION DATE..:
'# REVISION NOTES.:
'#
'#==============================================================================
'#==============================================================================
Set objShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
strStartMenu = objShell.SpecialFolders("StartMenu")
strAllUsersStartMenu = objShell.SpecialFolders("AllUsersStartMenu")
'#--------------------------------------------------------------------------
'# Add Any Excluded Folders in here. You will also need to increase the
'# arrExcludedFolders(x) array variable by 1.
'#--------------------------------------------------------------------------
Dim arrExcludedFolders(3)
arrExcludedFolders(0) = "programs"
arrExcludedFolders(1) = "programsaccessories*"
arrExcludedFolders(2) = "programsadministrative tools"
'#--------------------------------------------------------------------------
DeleteStartMenuItems strStartMenu, 0
DeleteStartMenuItems strAllUsersStartMenu, 1
'#--------------------------------------------------------------------------
'# SUBROUTINE.....: DeleteStartMenuItems(strFolder, intStartMenu)
'# PURPOSE........: Deletes all the folders with broken shortcuts in
'# the specified folder
'# ARGUMENTS......: strFolder = full path to the folder
'# intStartMenu = index of Start Menu type
'# EXAMPLE........: DeleteStartMenuItems("c:documents and settingsall usersstart menu", 0)
'# NOTES..........: intStartMenu Values:
'# 0 = Start Menu
'# 1 = All Users Start Menu
'#--------------------------------------------------------------------------
Sub DeleteStartMenuItems(strFolder, intStartMenu)
On Error Resume Next
booDelete = 0
booCheck = 1
Set objFolder = objFSO.GetFolder(strFolder)
If intStartMenu = 0 Then
strSM = strStartMenu
Else
strSM = strAllUsersStartMenu
End If
For i = 0 To UBound(arrExcludedFolders) - 1
strExcludedFolder = strSM & arrExcludedFolders(i)
If LCase(strFolder) = LCase(strSM) Then
booCheck = 0
Exit For
End If
If Right(strExcludedFolder, 2) = "*" Then
strExcludedFolder = Left(strExcludedFolder, Len(strExcludedFolder) - 2)
If InStr(LCase(strFolder), LCase(strExcludedFolder)) > 0 Then
booCheck = 0
Exit For
End If
Else
If InStr(LCase(strExcludedFolder) & "||", LCase(strFolder) & "||") > 0 Then
booCheck = 0
Exit For
End If
End If
Next
If booCheck = 1 Then
For Each objItem In objFolder.Files
strFullName = objFSO.GetAbsolutePathName(objItem)
If Right(LCase(objItem), 3) = "lnk" Then
Set objShortcut = objShell.CreateShortcut(strFullName)
strTarget = LCase(objShortcut.TargetPath)
If NOT objFSO.FileExists(strTarget) Then
'#--------------------------------------------------------------------------
'# Currently set up to ask on each folder deletion. To remove prompting
'# before deletion (risky) uncomment out the next line and comment out
'# ( ' ) the rest up to '#----- line below.
'#--------------------------------------------------------------------------
'booDelete = 1
DeletePrompt = MsgBox("Do you wish to delete the below Start Menu folder? " & _
vbCrLf & vbCrLf & objFolder & " ", vbQuestion+vbYesNo, "CleanUp Start Menu Items")
Err.Clear
If DeletePrompt = vbYes Then
booDelete = 1
Exit For
End If
'#--------------------------------------------------------------------------
End If
End If
Next
If booDelete = 1 Then objFolder.Delete True
End If
For Each objItem In objFolder.SubFolders
DeleteStartMenuItems objItem.Path, intStartMenu
Next
[/pre]
End Sub
SOURCE:
http://community.spiceworks.com/scripts/show/1078-cleanup-start-menu-items
Thank you in advance...
And Peace!
Devvie
[[User:Devnullius|Devnullius]]
notemail@facebook.com [[User:Devnullius|Devnullius]]
Cuisvis hominis est errare, nullius nisi insipientis in errore persevare
——
All spelling mistakes are my own and may only be distributed under the GNU General Public License! – (© 95-1 by Coredump; 2-012 by DevNullius)
PS:
http://www.asciitable.com/