frank_m
10-28-2010, 09:42 PM
I have a batch file that stops and re-starts the spooling service and removes print jobs from the spool\printers folder
With Windows Vista Home version, it can be run by right clicking and selecting run as administrator.
Is there any way to have the batch file automatically call up the permission to run popup?
Below is a partial snippet of a vbscript that can call up the prompt:
do while x="RunFileasAnmin"
If WScript.Arguments.Count = 0 Then
Set ObjShell = CreateObject("Shell.Application")
ObjShellthree.ShellExecute "wscript.exe", """" & _
WScript.ScriptFullName & """" & " RunAsAdmin", , "runas", 1
x="skipblockabove"
Set ObjShell = Nothing
End if
loop So I was hoping that something similar could be accomplished with a batch file. The reason I need it is because the batch file will be called using vba in Excel.
The batch file code is;
@echo off
cls
net stop spooler
del %systemroot%\system32\spool\printers\*.shd
del %systemroot%\system32\spool\printers\*.spl
net start spooler If not, then I guess I'll have to work at doing the procedure with vbscript.
I posted a related question in the Excel help section of this forum: http://www.vbaexpress.com/forum/showthread.php?p=228563#post228563
Thanks in advance
With Windows Vista Home version, it can be run by right clicking and selecting run as administrator.
Is there any way to have the batch file automatically call up the permission to run popup?
Below is a partial snippet of a vbscript that can call up the prompt:
do while x="RunFileasAnmin"
If WScript.Arguments.Count = 0 Then
Set ObjShell = CreateObject("Shell.Application")
ObjShellthree.ShellExecute "wscript.exe", """" & _
WScript.ScriptFullName & """" & " RunAsAdmin", , "runas", 1
x="skipblockabove"
Set ObjShell = Nothing
End if
loop So I was hoping that something similar could be accomplished with a batch file. The reason I need it is because the batch file will be called using vba in Excel.
The batch file code is;
@echo off
cls
net stop spooler
del %systemroot%\system32\spool\printers\*.shd
del %systemroot%\system32\spool\printers\*.spl
net start spooler If not, then I guess I'll have to work at doing the procedure with vbscript.
I posted a related question in the Excel help section of this forum: http://www.vbaexpress.com/forum/showthread.php?p=228563#post228563
Thanks in advance